diff --git a/lcl/grids.pas b/lcl/grids.pas index 8f0e91d8c3..d49cba3377 100644 --- a/lcl/grids.pas +++ b/lcl/grids.pas @@ -4500,6 +4500,7 @@ procedure TCustomGrid.WMKillFocus(var message: TLMKillFocus); begin if csDestroying in ComponentState then exit; + debugln(['TCustomGrid.WMKillFocus BBB1 ',DbgSName(Self)]); {$ifdef dbgGrid} DbgOut('*** grid.WMKillFocus, FocusedWnd=%x WillFocus=',[Message.FocusedWnd]); if EditorMode and (Message.FocusedWnd = FEditor.Handle) then @@ -4518,6 +4519,7 @@ end; procedure TCustomGrid.WMSetFocus(var message: TLMSetFocus); begin + debugln(['TCustomGrid.WMSetFocus BBB2 ',DbgSName(Self)]); {$ifdef dbgGrid} DbgOut('*** grid.WMSetFocus, FocusedWnd=', dbgs(Message.FocusedWnd),'[',dbgs(pointer(Message.FocusedWnd)),'] '); if EditorMode and (Message.FocusedWnd = FEditor.Handle) then diff --git a/lcl/interfaces/gtk2/gtk2winapiwindow.pp b/lcl/interfaces/gtk2/gtk2winapiwindow.pp index 2fd178efa8..56f6a81c8b 100644 --- a/lcl/interfaces/gtk2/gtk2winapiwindow.pp +++ b/lcl/interfaces/gtk2/gtk2winapiwindow.pp @@ -954,12 +954,24 @@ end; function GTKAPIWidget_FocusIn(Widget: PGTKWidget; {%H-}Event: PGdkEventFocus): GTKEventResult; cdecl; var - TopLevel: PGTKWidget; + TopLevel, FocusWidget: PGTKWidget; begin TopLevel := gtk_widget_get_toplevel(Widget); if gtk_type_is_a(gtk_object_type(PGTKObject(TopLevel)), gtk_window_get_type) - then gtk_window_set_focus(PGTKWindow(TopLevel), PGTKAPIWidget(Widget)^.Client); - + then begin + if GTK_WIDGET_CAN_FOCUS(PGTKAPIWidget(Widget)^.Client) then + FocusWidget:=PGTKAPIWidget(Widget)^.Client + else + FocusWidget:=Widget; + {debugln(['GTKAPIWidget_FocusIn ', + ' Widget=',GetWidgetDebugReport(Widget), + ' Client=',GetWidgetDebugReport(PGTKAPIWidget(Widget)^.Client), + ' GTK_WIDGET_CAN_FOCUS(Widget)=',GTK_WIDGET_CAN_FOCUS(Widget), + ' GTK_WIDGET_CAN_FOCUS(Client)=',GTK_WIDGET_CAN_FOCUS(PGTKAPIWidget(Widget)^.Client), + '']);} + gtk_window_set_focus(PGTKWindow(TopLevel), FocusWidget); + end; + Result := gtk_True; end;