lcl: gtk2: GTKAPIWidget_FocusIn: check if client widget can be focused

git-svn-id: trunk@52558 -
This commit is contained in:
mattias 2016-06-22 14:34:20 +00:00
parent 4c9d5e70ca
commit 03e749be43
2 changed files with 17 additions and 3 deletions

View File

@ -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

View File

@ -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;