cocoa: forcing focus set on Showing window through WS ShowHide method

git-svn-id: trunk@62407 -
This commit is contained in:
dmitry 2019-12-17 03:41:03 +00:00
parent 98aa637a42
commit a21894d597

View File

@ -331,9 +331,20 @@ end;
{ TLCLWindowCallback }
type
TWinControlAccess = class(TWinControl)
end;
function TLCLWindowCallback.CanActivate: Boolean;
begin
Result := Enabled;
// it's possible that a Modal window requests this (target) window
// to become visible (i.e. when modal is closing)
// All other Windows are disabled while modal is active.
// Thus must check wcfUpdateShowing flag (which set when changing window visibility)
// And if it's used, then we allow the window to become Key window
if not Result and (Target is TWinControl) then
Result := wcfUpdateShowing in TWinControlAccess(Target).FWinControlFlags;
end;
constructor TLCLWindowCallback.Create(AOwner: NSObject; ATarget: TWinControl; AHandleView: NSView);
@ -1101,11 +1112,11 @@ begin
end
else
begin
w := TCocoaWindowContent(AWinControl.Handle).lclOwnWindow;
if not lShow then
begin
// macOS 10.6. If a window with a parent window is hidden, then parent is also hidden.
// Detaching from the parent first!
w := TCocoaWindowContent(AWinControl.Handle).lclOwnWindow;
if Assigned(w) and Assigned(w.parentWindow) then
w.parentWindow.removeChildWindow(w);
// if the same control needs to be shown again, it will be redrawn
@ -1113,6 +1124,10 @@ begin
TCocoaWindowContent(AWinControl.Handle).documentView.setNeedsDisplay_(true);
end;
TCocoaWSWinControl.ShowHide(AWinControl);
// ShowHide() also actives (sets focus to) the window
if lShow and Assigned(w) then
w.makeKeyWindow;
end;
if (lShow) then