mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-19 23:19:30 +02:00
lcl: redo cm_activate, cm_deactivate for showmodal - not it works consistently on win32, qt and gtk2
git-svn-id: trunk@25300 -
This commit is contained in:
parent
2648d29b7f
commit
0868cb6177
@ -943,7 +943,6 @@ type
|
|||||||
procedure AddForm(AForm: TCustomForm);
|
procedure AddForm(AForm: TCustomForm);
|
||||||
procedure RemoveForm(AForm: TCustomForm);
|
procedure RemoveForm(AForm: TCustomForm);
|
||||||
function SetFocusedForm(AForm: TCustomForm; AModal: Boolean): Boolean;
|
function SetFocusedForm(AForm: TCustomForm; AModal: Boolean): Boolean;
|
||||||
procedure RestoreFocusedForm;
|
|
||||||
procedure SetCursor(const AValue: TCursor);
|
procedure SetCursor(const AValue: TCursor);
|
||||||
procedure SetCursors(AIndex: Integer; const AValue: HCURSOR);
|
procedure SetCursors(AIndex: Integer; const AValue: HCURSOR);
|
||||||
procedure SetHintFont(const AValue: TFont);
|
procedure SetHintFont(const AValue: TFont);
|
||||||
|
@ -2504,6 +2504,19 @@ function TCustomForm.ShowModal: Integer;
|
|||||||
raise EInvalidOperation.Create('TCustomForm.ShowModal impossible ');
|
raise EInvalidOperation.Create('TCustomForm.ShowModal impossible ');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure RestoreFocusedForm;
|
||||||
|
begin
|
||||||
|
// needs to be called only in ShowModal
|
||||||
|
Perform(CM_DEACTIVATE, 0, 0);
|
||||||
|
if Screen.FSaveFocusedList.Count > 0 then
|
||||||
|
begin
|
||||||
|
Screen.FFocusedForm := TCustomForm(Screen.FSaveFocusedList.First);
|
||||||
|
Screen.FSaveFocusedList.Remove(Screen.FFocusedForm);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Screen.FFocusedForm := nil;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
DisabledList: TList;
|
DisabledList: TList;
|
||||||
SavedFocusState: TFocusState;
|
SavedFocusState: TFocusState;
|
||||||
@ -2530,6 +2543,8 @@ begin
|
|||||||
Include(FFormState, fsModal);
|
Include(FFormState, fsModal);
|
||||||
ActiveWindow := GetActiveWindow;
|
ActiveWindow := GetActiveWindow;
|
||||||
SavedFocusState := SaveFocusState;
|
SavedFocusState := SaveFocusState;
|
||||||
|
Screen.FSaveFocusedList.Insert(0, Screen.FFocusedForm);
|
||||||
|
Screen.FFocusedForm := Self;
|
||||||
Screen.MoveFormToFocusFront(Self);
|
Screen.MoveFormToFocusFront(Self);
|
||||||
Screen.MoveFormToZFront(Self);
|
Screen.MoveFormToZFront(Self);
|
||||||
ModalResult := 0;
|
ModalResult := 0;
|
||||||
@ -2542,7 +2557,7 @@ begin
|
|||||||
Show;
|
Show;
|
||||||
try
|
try
|
||||||
// activate must happen after show
|
// activate must happen after show
|
||||||
Screen.SetFocusedForm(Self, True);
|
Perform(CM_ACTIVATE, 0, 0);
|
||||||
TWSCustomFormClass(WidgetSetClass).ShowModal(Self);
|
TWSCustomFormClass(WidgetSetClass).ShowModal(Self);
|
||||||
repeat
|
repeat
|
||||||
{ Delphi calls Application.HandleMessage
|
{ Delphi calls Application.HandleMessage
|
||||||
@ -2571,7 +2586,7 @@ begin
|
|||||||
Result := ModalResult;
|
Result := ModalResult;
|
||||||
if HandleAllocated and (GetActiveWindow <> Handle) then
|
if HandleAllocated and (GetActiveWindow <> Handle) then
|
||||||
ActiveWindow := 0;
|
ActiveWindow := 0;
|
||||||
Screen.RestoreFocusedForm;
|
RestoreFocusedForm;
|
||||||
finally
|
finally
|
||||||
Screen.EnableForms(DisabledList);
|
Screen.EnableForms(DisabledList);
|
||||||
{ guarantee execution of widgetset CloseModal }
|
{ guarantee execution of widgetset CloseModal }
|
||||||
|
@ -772,20 +772,15 @@ begin
|
|||||||
Result := True;
|
Result := True;
|
||||||
if FFocusedForm <> AForm then
|
if FFocusedForm <> AForm then
|
||||||
begin
|
begin
|
||||||
if not AModal then
|
// send deactivate to the previosly focused form
|
||||||
|
LastState := SaveFocusState;
|
||||||
|
if FFocusedForm <> nil then
|
||||||
|
FFocusedForm.Perform(CM_DEACTIVATE, 0, 0);
|
||||||
|
if SaveFocusState <> LastState then
|
||||||
begin
|
begin
|
||||||
// send deactivate to the previosly focused form
|
FFocusedForm := nil;
|
||||||
LastState := SaveFocusState;
|
Exit(False);
|
||||||
if FFocusedForm <> nil then
|
end;
|
||||||
FFocusedForm.Perform(CM_DEACTIVATE, 0, 0);
|
|
||||||
if SaveFocusState <> LastState then
|
|
||||||
begin
|
|
||||||
FFocusedForm := nil;
|
|
||||||
Exit(False);
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
FSaveFocusedList.Insert(0, FFocusedForm);
|
|
||||||
// send activate to the newly focused form
|
// send activate to the newly focused form
|
||||||
FFocusedForm := AForm;
|
FFocusedForm := AForm;
|
||||||
LastState := SaveFocusState;
|
LastState := SaveFocusState;
|
||||||
@ -796,20 +791,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TScreen.RestoreFocusedForm;
|
|
||||||
begin
|
|
||||||
// needs to be called with sync with SetFocusedForm only in ShowModal
|
|
||||||
if FFocusedForm <> nil then
|
|
||||||
FFocusedForm.Perform(CM_DEACTIVATE, 0, 0);
|
|
||||||
if FSaveFocusedList.Count > 0 then
|
|
||||||
begin
|
|
||||||
FFocusedForm := TCustomForm(FSaveFocusedList.First);
|
|
||||||
FSaveFocusedList.Remove(Screen.FFocusedForm);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
FFocusedForm := nil;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
procedure TScreen.SetCursor(const AValue: TCursor);
|
procedure TScreen.SetCursor(const AValue: TCursor);
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
|
Loading…
Reference in New Issue
Block a user