mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 07:38:14 +02:00
lcl: send CM_ACTIVATE, CM_DEACTIVATE for modal forms
git-svn-id: trunk@25294 -
This commit is contained in:
parent
77895ca1a7
commit
581c468507
@ -943,6 +943,7 @@ type
|
||||
procedure AddForm(AForm: TCustomForm);
|
||||
procedure RemoveForm(AForm: TCustomForm);
|
||||
function SetFocusedForm(AForm: TCustomForm): Boolean;
|
||||
procedure RestoreFocusedForm;
|
||||
procedure SetCursor(const AValue: TCursor);
|
||||
procedure SetCursors(AIndex: Integer; const AValue: HCURSOR);
|
||||
procedure SetHintFont(const AValue: TFont);
|
||||
|
@ -2530,8 +2530,6 @@ 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;
|
||||
@ -2543,6 +2541,8 @@ begin
|
||||
DisabledList := nil;
|
||||
Show;
|
||||
try
|
||||
// activate must happen after show
|
||||
Screen.SetFocusedForm(Self);
|
||||
TWSCustomFormClass(WidgetSetClass).ShowModal(Self);
|
||||
repeat
|
||||
{ Delphi calls Application.HandleMessage
|
||||
@ -2571,6 +2571,7 @@ begin
|
||||
Result := ModalResult;
|
||||
if HandleAllocated and (GetActiveWindow <> Handle) then
|
||||
ActiveWindow := 0;
|
||||
Screen.RestoreFocusedForm;
|
||||
finally
|
||||
Screen.EnableForms(DisabledList);
|
||||
{ guarantee execution of widgetset CloseModal }
|
||||
@ -2583,13 +2584,6 @@ begin
|
||||
DestroyHandle;
|
||||
end;
|
||||
finally
|
||||
if Screen.FSaveFocusedList.Count > 0 then
|
||||
begin
|
||||
Screen.FFocusedForm := TCustomForm(Screen.FSaveFocusedList.First);
|
||||
Screen.FSaveFocusedList.Remove(Screen.FFocusedForm);
|
||||
end
|
||||
else
|
||||
Screen.FFocusedForm := nil;
|
||||
RestoreFocusState(SavedFocusState);
|
||||
if LCLIntf.IsWindow(ActiveWindow) then
|
||||
SetActiveWindow(ActiveWindow);
|
||||
|
@ -772,15 +772,20 @@ begin
|
||||
Result := True;
|
||||
if FFocusedForm <> AForm 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
|
||||
if not (fsModal in AForm.FormState) then
|
||||
begin
|
||||
FFocusedForm := nil;
|
||||
Exit(False);
|
||||
end;
|
||||
// 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);
|
||||
// send activate to the newly focused form
|
||||
FFocusedForm := AForm;
|
||||
LastState := SaveFocusState;
|
||||
@ -791,6 +796,20 @@ 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