mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-20 12:19:31 +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 RemoveForm(AForm: TCustomForm);
|
||||
function SetFocusedForm(AForm: TCustomForm; AModal: Boolean): Boolean;
|
||||
procedure RestoreFocusedForm;
|
||||
procedure SetCursor(const AValue: TCursor);
|
||||
procedure SetCursors(AIndex: Integer; const AValue: HCURSOR);
|
||||
procedure SetHintFont(const AValue: TFont);
|
||||
|
@ -2504,6 +2504,19 @@ function TCustomForm.ShowModal: Integer;
|
||||
raise EInvalidOperation.Create('TCustomForm.ShowModal impossible ');
|
||||
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
|
||||
DisabledList: TList;
|
||||
SavedFocusState: TFocusState;
|
||||
@ -2530,6 +2543,8 @@ begin
|
||||
Include(FFormState, fsModal);
|
||||
ActiveWindow := GetActiveWindow;
|
||||
SavedFocusState := SaveFocusState;
|
||||
Screen.FSaveFocusedList.Insert(0, Screen.FFocusedForm);
|
||||
Screen.FFocusedForm := Self;
|
||||
Screen.MoveFormToFocusFront(Self);
|
||||
Screen.MoveFormToZFront(Self);
|
||||
ModalResult := 0;
|
||||
@ -2542,7 +2557,7 @@ begin
|
||||
Show;
|
||||
try
|
||||
// activate must happen after show
|
||||
Screen.SetFocusedForm(Self, True);
|
||||
Perform(CM_ACTIVATE, 0, 0);
|
||||
TWSCustomFormClass(WidgetSetClass).ShowModal(Self);
|
||||
repeat
|
||||
{ Delphi calls Application.HandleMessage
|
||||
@ -2571,7 +2586,7 @@ begin
|
||||
Result := ModalResult;
|
||||
if HandleAllocated and (GetActiveWindow <> Handle) then
|
||||
ActiveWindow := 0;
|
||||
Screen.RestoreFocusedForm;
|
||||
RestoreFocusedForm;
|
||||
finally
|
||||
Screen.EnableForms(DisabledList);
|
||||
{ guarantee execution of widgetset CloseModal }
|
||||
|
@ -772,20 +772,15 @@ begin
|
||||
Result := True;
|
||||
if FFocusedForm <> AForm then
|
||||
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
|
||||
// send deactivate to the previosly focused form
|
||||
LastState := SaveFocusState;
|
||||
if FFocusedForm <> nil then
|
||||
FFocusedForm.Perform(CM_DEACTIVATE, 0, 0);
|
||||
if SaveFocusState <> LastState then
|
||||
begin
|
||||
FFocusedForm := nil;
|
||||
Exit(False);
|
||||
end;
|
||||
end
|
||||
else
|
||||
FSaveFocusedList.Insert(0, FFocusedForm);
|
||||
FFocusedForm := nil;
|
||||
Exit(False);
|
||||
end;
|
||||
// send activate to the newly focused form
|
||||
FFocusedForm := AForm;
|
||||
LastState := SaveFocusState;
|
||||
@ -796,20 +791,6 @@ begin
|
||||
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);
|
||||
------------------------------------------------------------------------------}
|
||||
|
Loading…
Reference in New Issue
Block a user