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