mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 17:29:31 +02:00
Cocoa: fix #40692, the bug of Modal Window
This commit is contained in:
parent
7157791611
commit
6f8a824944
@ -171,7 +171,6 @@ type
|
|||||||
procedure DoSetMainMenu(AMenu: NSMenu; ALCLMenu: TMenu);
|
procedure DoSetMainMenu(AMenu: NSMenu; ALCLMenu: TMenu);
|
||||||
public
|
public
|
||||||
// modal session
|
// modal session
|
||||||
CurModalForm: NSWindow;
|
|
||||||
Modals : TList;
|
Modals : TList;
|
||||||
ModalCounter: Integer; // the cheapest way to determine if modal window was called
|
ModalCounter: Integer; // the cheapest way to determine if modal window was called
|
||||||
// used in mouse handling (in callbackobject)
|
// used in mouse handling (in callbackobject)
|
||||||
@ -218,6 +217,7 @@ type
|
|||||||
procedure SetMainMenu(const AMenu: HMENU; const ALCLMenu: TMenu);
|
procedure SetMainMenu(const AMenu: HMENU; const ALCLMenu: TMenu);
|
||||||
function StartModal(awin: NSWindow; hasMenu: Boolean): Boolean;
|
function StartModal(awin: NSWindow; hasMenu: Boolean): Boolean;
|
||||||
procedure EndModal(awin: NSWindow);
|
procedure EndModal(awin: NSWindow);
|
||||||
|
function CurModalForm: NSWindow;
|
||||||
function isTopModalWin(awin: NSWindow): Boolean;
|
function isTopModalWin(awin: NSWindow): Boolean;
|
||||||
function isModalSession: Boolean;
|
function isModalSession: Boolean;
|
||||||
|
|
||||||
@ -946,13 +946,22 @@ begin
|
|||||||
wakeupEventLoop;
|
wakeupEventLoop;
|
||||||
end;
|
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;
|
function TCocoaWidgetSet.isTopModalWin(awin: NSWindow): Boolean;
|
||||||
begin
|
begin
|
||||||
if not isModalSession then begin
|
if Assigned(awin) then begin
|
||||||
Result := false;
|
Result:= CurModalForm=awin;
|
||||||
Exit;
|
end else begin
|
||||||
|
Result:= false;
|
||||||
end;
|
end;
|
||||||
Result := TModalSession(Modals[Modals.Count-1]).window = awin;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCocoaWidgetSet.isModalSession: Boolean;
|
function TCocoaWidgetSet.isModalSession: Boolean;
|
||||||
|
@ -411,7 +411,6 @@ begin
|
|||||||
{$IFDEF COCOA_USE_NATIVE_MODAL}
|
{$IFDEF COCOA_USE_NATIVE_MODAL}
|
||||||
NSApp.stopModal();
|
NSApp.stopModal();
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
CocoaWidgetSet.CurModalForm := nil;
|
|
||||||
{// Felipe: This code forces focusing another form, its a work around
|
{// Felipe: This code forces focusing another form, its a work around
|
||||||
// for a gdb issue, gdb doesn't start the app properly
|
// 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
|
if (not fullscreen) and (lWinContent.window.isKindOfClass(TCocoaWindow)) then
|
||||||
fullscreen := TCocoaWindow(lWinContent.window).lclIsFullScreen;
|
fullscreen := TCocoaWindow(lWinContent.window).lclIsFullScreen;
|
||||||
|
|
||||||
CocoaWidgetSet.CurModalForm := lWinContent.lclOwnWindow;
|
|
||||||
// LCL initialization code would cause the custom form to be disabled
|
// 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
|
// (due to the fact, ShowModal() has not been called yet, and a previous form
|
||||||
// might be disabled at the time.
|
// might be disabled at the time.
|
||||||
|
Loading…
Reference in New Issue
Block a user