mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-04 08:18:29 +02:00
Gtk2: inform lcl when return pressed on GtkButton, so it can update internal varibles or properties. issue #21483
git-svn-id: trunk@36032 -
This commit is contained in:
parent
badac6ae4a
commit
d734ac880e
@ -2149,6 +2149,28 @@ var
|
||||
// the gtk2 gtkentry handles the return key and emits an activate signal
|
||||
// The LCL does not use that and needs the return key event
|
||||
// => emulate it
|
||||
|
||||
// emulate VK_RETURN on GtkButton. issue #21483
|
||||
if GtkWidgetIsA(TargetWidget, gtk_type_button) then
|
||||
begin
|
||||
if (gdk_event_get_type(AEvent) = GDK_KEY_RELEASE) and
|
||||
(VKey = VK_RETURN) then
|
||||
begin
|
||||
FillChar(Msg, SizeOf(Msg), 0);
|
||||
Msg.CharCode := VKey;
|
||||
if SysKey then
|
||||
Msg.msg := LM_SYSKEYUP
|
||||
else
|
||||
Msg.msg := LM_KEYUP;
|
||||
Msg.KeyData := CommonKeyData or (Flags shl 16) or $0001 {TODO: repeatcount};
|
||||
// do not send next LM_CLICKED. issue #21483
|
||||
g_object_set_data(PGObject(TargetWidget),'lcl-button-stop-clicked', TargetWidget);
|
||||
NotifyApplicationUserInput(TControl(TargetObj), Msg.Msg);
|
||||
DeliverKeyMessage(TargetObj, Msg);
|
||||
end;
|
||||
|
||||
end else
|
||||
|
||||
if (
|
||||
GtkWidgetIsA(TargetWidget, gtk_type_entry) or
|
||||
GtkWidgetIsA(TargetWidget, gtk_type_text_view)
|
||||
|
@ -2280,10 +2280,25 @@ var
|
||||
begin
|
||||
Result := CallBackDefaultReturn;
|
||||
if AInfo^.ChangeLock > 0 then Exit;
|
||||
|
||||
// do not send LM_CLICKED. issue #21483
|
||||
if g_object_get_data(PGObject(AWidget),'lcl-button-stop-clicked') = AWidget then
|
||||
begin
|
||||
g_object_set_data(PGObject(AWidget),'lcl-button-stop-clicked', nil);
|
||||
exit;
|
||||
end;
|
||||
Msg.Msg := LM_CLICKED;
|
||||
Result := DeliverMessage(AInfo^.LCLObject, Msg) = 0;
|
||||
end;
|
||||
|
||||
function Gtk2WSButtonPressedEvent(widget: PGtkWidget; event: pgdkEventButton; data: gPointer): GBoolean; cdecl;
|
||||
begin
|
||||
Result := CallBackDefaultReturn;
|
||||
// set to nil data if we pressed return before,
|
||||
// otherwise LM_CLICKED won't trigger. issue #21483
|
||||
g_object_set_data(PGObject(Widget),'lcl-button-stop-clicked', nil);
|
||||
end;
|
||||
|
||||
procedure Gtk2WSButton_SizeAllocate(widget: PGtkWidget; allocation: PGtkAllocation; user_data: gpointer); cdecl;
|
||||
var
|
||||
xthickness, ythickness: gint;
|
||||
@ -2339,6 +2354,7 @@ class procedure TGtk2WSButton.SetCallbacks(const AGtkWidget: PGtkWidget;
|
||||
begin
|
||||
TGtk2WSWinControl.SetCallbacks(PGtkObject(AGtkWidget), TComponent(AWidgetInfo^.LCLObject));
|
||||
SignalConnect(AWidgetInfo^.CoreWidget, 'clicked', @Gtk2WSButton_Clicked, AWidgetInfo);
|
||||
SignalConnect(AWidgetInfo^.CoreWidget, 'button-press-event', @Gtk2WSButtonPressedEvent, AWidgetInfo);
|
||||
SignalConnect(AWidgetInfo^.CoreWidget, 'size-allocate', @Gtk2WSButton_SizeAllocate, AWidgetInfo);
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user