carbon: fix focusing, allowing an empty form to gain focus. bugs #16823,#16866

git-svn-id: trunk@27041 -
This commit is contained in:
dmitry 2010-08-08 20:47:27 +00:00
parent fa651f6d59
commit 3048fbf9e9

View File

@ -918,7 +918,7 @@ var
DoActivate: Boolean;
EventKind: UInt32;
Control: ControlRef;
FocusWidget: TCarbonControl;
FocusWidget: TCarbonWidget;
begin
{$IFDEF VerboseWindowEvent}
DebugLn('CarbonWindow_ActivateProc ', DbgSName(AWidget.LCLObject));
@ -952,13 +952,18 @@ begin
// force set and kill focus of focused control
Control := nil;
OSError(GetKeyboardFocus(TCarbonWindow(AWidget).fWindowRef, Control), 'CarbonWindow_ActivateProc', SGetKeyboardFocus);
if Control <> nil then
begin
FocusWidget := GetCarbonControl(Control);
if Control <> nil
then FocusWidget := GetCarbonControl(Control)
else FocusWidget := nil;
if FocusWidget <> nil then
if DoActivate then FocusWidget.FocusSet
else FocusWidget.FocusKilled;
// Focusing the form without controls
if (FocusWidget = nil) and DoActivate then FocusWidget:=AWidget;
if FocusWidget <> nil then
begin
if DoActivate
then FocusWidget.FocusSet
else FocusWidget.FocusKilled;
end;
end;