mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-07 12:44:00 +02:00
Qt: fixed bug when QMdiArea loose it's focusWidget during activation of mdichild (it's qt bug, so this is workaround for it).
git-svn-id: trunk@33393 -
This commit is contained in:
parent
79ecb7463b
commit
2e88b329aa
@ -5036,16 +5036,13 @@ end;
|
|||||||
|
|
||||||
procedure TQtMDIArea.SubWindowActivated(AWindow: QMDISubWindowH); cdecl;
|
procedure TQtMDIArea.SubWindowActivated(AWindow: QMDISubWindowH); cdecl;
|
||||||
var
|
var
|
||||||
i: Integer;
|
|
||||||
Arr: TPtrIntArray;
|
|
||||||
ActiveChild: TQtMainWindow;
|
ActiveChild: TQtMainWindow;
|
||||||
InActiveChild: TQtMainWindow;
|
|
||||||
H: HWND;
|
H: HWND;
|
||||||
|
W: QWidgetH;
|
||||||
|
WW: TQtWidget;
|
||||||
begin
|
begin
|
||||||
// when AWindow = nil then there's no mdichildren at all
|
{we must fix qt bugs here. QWidget_focusWidget() is lost when
|
||||||
// so only valid state is AWindow <> nil
|
activating mdichild via BringToFront (eg from menu)}
|
||||||
{DO NOT USE THIS FOR NOW, MAYBE WILL BE REMOVED, MAKES PROBLEMS WITH FOCUS
|
|
||||||
QMdiArea_subWindowList(QMdiAreaH(Widget), @Arr);
|
|
||||||
if AWindow <> nil then
|
if AWindow <> nil then
|
||||||
begin
|
begin
|
||||||
H := HwndFromWidgetH(AWindow);
|
H := HwndFromWidgetH(AWindow);
|
||||||
@ -5053,20 +5050,42 @@ begin
|
|||||||
ActiveChild := TQtMainWindow(H)
|
ActiveChild := TQtMainWindow(H)
|
||||||
else
|
else
|
||||||
ActiveChild := nil;
|
ActiveChild := nil;
|
||||||
for i := 0 to High(Arr) do
|
|
||||||
|
if ActiveChild = nil then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
W := QWidget_focusWidget(AWindow);
|
||||||
|
if W <> nil then
|
||||||
begin
|
begin
|
||||||
H := HwndFromWidgetH(AWindow);
|
H := HwndFromWidgetH(W);
|
||||||
if H <> 0 then
|
if H <> 0 then
|
||||||
begin
|
begin
|
||||||
InActiveChild := TQtMainWindow(H);
|
WW := TQtWidget(H);
|
||||||
if (InactiveChild <> ActiveChild) and TCustomForm(InActiveChild.LCLObject).Active then
|
{$IF DEFINED(VerboseFocus) OR DEFINED(DebugQtFocus)}
|
||||||
InActiveChild.SlotActivateWindow(False);
|
writeln('TQtMDIArea.SubWindowActivated: *=* Current focus widget ',dbgsName(WW.LCLObject));
|
||||||
|
{$ENDIF}
|
||||||
|
{trigger QMDIArea to update it's focusWidget (it could be nil) }
|
||||||
|
QWidget_setFocus(WW.Widget, QtActiveWindowFocusReason);
|
||||||
|
end;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
// fallback when qt completely looses it's mind about focusWidget() inside
|
||||||
|
// mdi form.
|
||||||
|
{$IF DEFINED(VerboseFocus) OR DEFINED(DebugQtFocus)}
|
||||||
|
writeln('TQtMDIArea.SubWindowActivated: fallback - ask TCustomForm.ActiveControl ',
|
||||||
|
dbgsName(TCustomForm(ActiveChild.LCLObject).ActiveControl));
|
||||||
|
{$ENDIF}
|
||||||
|
if Assigned(TCustomForm(ActiveChild.LCLObject).ActiveControl) and
|
||||||
|
TCustomForm(ActiveChild.LCLObject).ActiveControl.HandleAllocated then
|
||||||
|
begin
|
||||||
|
WW := TQtWidget(TCustomForm(ActiveChild.LCLObject).ActiveControl.Handle);
|
||||||
|
{$IF DEFINED(VerboseFocus) OR DEFINED(DebugQtFocus)}
|
||||||
|
writeln('**** SUCCESFULLY ACTIVATED FOCUS PATCH ****');
|
||||||
|
{$ENDIF}
|
||||||
|
QWidget_setFocus(WW.Widget, QtActiveWindowFocusReason);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if ActiveChild <> nil then
|
|
||||||
ActiveChild.SlotActivateWindow(True);
|
|
||||||
end;
|
end;
|
||||||
}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TQtMDIArea.Create(const AParent: QWidgetH);
|
constructor TQtMDIArea.Create(const AParent: QWidgetH);
|
||||||
|
Loading…
Reference in New Issue
Block a user