diff --git a/lcl/interfaces/cocoa/cocoaint.pas b/lcl/interfaces/cocoa/cocoaint.pas index 6fd83f86b6..cfc05c48c4 100644 --- a/lcl/interfaces/cocoa/cocoaint.pas +++ b/lcl/interfaces/cocoa/cocoaint.pas @@ -171,7 +171,6 @@ type procedure DoSetMainMenu(AMenu: NSMenu; ALCLMenu: TMenu); public // modal session - CurModalForm: NSWindow; Modals : TList; ModalCounter: Integer; // the cheapest way to determine if modal window was called // used in mouse handling (in callbackobject) @@ -218,6 +217,7 @@ type procedure SetMainMenu(const AMenu: HMENU; const ALCLMenu: TMenu); function StartModal(awin: NSWindow; hasMenu: Boolean): Boolean; procedure EndModal(awin: NSWindow); + function CurModalForm: NSWindow; function isTopModalWin(awin: NSWindow): Boolean; function isModalSession: Boolean; @@ -946,13 +946,22 @@ begin wakeupEventLoop; end; +function TCocoaWidgetSet.CurModalForm: NSWindow; +begin + if isModalSession then begin + Result := TModalSession(Modals[Modals.Count-1]).window; + end else begin + Result:= nil; + end; +end; + function TCocoaWidgetSet.isTopModalWin(awin: NSWindow): Boolean; begin - if not isModalSession then begin - Result := false; - Exit; + if Assigned(awin) then begin + Result:= CurModalForm=awin; + end else begin + Result:= false; end; - Result := TModalSession(Modals[Modals.Count-1]).window = awin; end; function TCocoaWidgetSet.isModalSession: Boolean; diff --git a/lcl/interfaces/cocoa/cocoawsforms.pas b/lcl/interfaces/cocoa/cocoawsforms.pas index 4b2cbc4907..b782ae905d 100644 --- a/lcl/interfaces/cocoa/cocoawsforms.pas +++ b/lcl/interfaces/cocoa/cocoawsforms.pas @@ -411,7 +411,6 @@ begin {$IFDEF COCOA_USE_NATIVE_MODAL} NSApp.stopModal(); {$ENDIF} - CocoaWidgetSet.CurModalForm := nil; {// Felipe: This code forces focusing another form, its a work around // for a gdb issue, gdb doesn't start the app properly // @@ -936,7 +935,6 @@ begin if (not fullscreen) and (lWinContent.window.isKindOfClass(TCocoaWindow)) then fullscreen := TCocoaWindow(lWinContent.window).lclIsFullScreen; - CocoaWidgetSet.CurModalForm := lWinContent.lclOwnWindow; // LCL initialization code would cause the custom form to be disabled // (due to the fact, ShowModal() has not been called yet, and a previous form // might be disabled at the time.