mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-04 05:58:14 +02:00
Qt: fixed TQtWidgetSet.SetFocus(), it should activate parent form if we call setfocus for control which is on inactive form.
git-svn-id: trunk@27614 -
This commit is contained in:
parent
68863ce1c3
commit
ae23055240
@ -219,6 +219,7 @@ type
|
||||
function getHeight: Integer;
|
||||
function getUpdatesEnabled: Boolean;
|
||||
function getWidth: Integer;
|
||||
function getWindow: TQtWidget;
|
||||
function getWindowState: QtWindowStates;
|
||||
procedure grabMouse; virtual;
|
||||
function hasFocus: Boolean; virtual;
|
||||
@ -491,6 +492,7 @@ type
|
||||
|
||||
TQtMainWindow = class(TQtWidget)
|
||||
private
|
||||
FBlocked: Boolean;
|
||||
LayoutWidget: QBoxLayoutH;
|
||||
FCWEventHook: QObject_hookH;
|
||||
FShowOnTaskBar: Boolean;
|
||||
@ -524,6 +526,7 @@ type
|
||||
procedure slotWindowStateChange; cdecl;
|
||||
procedure setShowInTaskBar(AValue: Boolean);
|
||||
procedure setPopupParent(APopupMode: TPopupMode; NewParent: QWidgetH);
|
||||
property Blocked: Boolean read FBlocked write FBlocked;
|
||||
property ShowOnTaskBar: Boolean read FShowOnTaskBar;
|
||||
public
|
||||
procedure AttachEvents; override;
|
||||
@ -3498,6 +3501,16 @@ begin
|
||||
Result := QWidget_width(Widget);
|
||||
end;
|
||||
|
||||
function TQtWidget.getWindow: TQtWidget;
|
||||
var
|
||||
W: QWidgetH;
|
||||
begin
|
||||
Result := nil;
|
||||
W := QWidget_window(Widget);
|
||||
if W <> nil then
|
||||
Result := TQtWidget(HwndFromWidgetH(W));
|
||||
end;
|
||||
|
||||
function TQtWidget.getWindowState: QtWindowStates;
|
||||
begin
|
||||
Result := QWidget_windowState(Widget);
|
||||
@ -4581,6 +4594,7 @@ begin
|
||||
{$ifdef VerboseQt}
|
||||
WriteLn('TQtMainWindow.CreateWidget Name: ', LCLObject.Name);
|
||||
{$endif}
|
||||
FBlocked := False;
|
||||
FShowOnTaskBar := False;
|
||||
QtFormBorderStyle := Ord(bsSizeable);
|
||||
QtFormStyle := Ord(fsNormal);
|
||||
@ -4821,6 +4835,8 @@ begin
|
||||
|
||||
BeginEventProcessing;
|
||||
case QEvent_type(Event) of
|
||||
QEventWindowUnblocked: Blocked := False;
|
||||
QEventWindowBlocked: Blocked := True;
|
||||
QEventWindowActivate: SlotActivateWindow(True);
|
||||
QEventWindowDeactivate: SlotActivateWindow(False);
|
||||
QEventShowToParent:
|
||||
|
@ -4881,6 +4881,8 @@ end;
|
||||
|
||||
------------------------------------------------------------------------------}
|
||||
function TQtWidgetSet.SetFocus(hWnd: HWND): HWND;
|
||||
var
|
||||
W: TQtWidget;
|
||||
begin
|
||||
Result := 0;
|
||||
if hwnd<>0 then
|
||||
@ -4889,6 +4891,10 @@ begin
|
||||
WriteLn('********* TQtWidgetSet.SetFocus INIT focusing ', TQtWidget(hwnd).lclobject.name);
|
||||
{$endif}
|
||||
Result := GetFocus;
|
||||
W := TQtWidget(HWND).getWindow;
|
||||
if (W <> nil) and not W.IsActiveWindow and
|
||||
not TQtMainWindow(W).Blocked then
|
||||
W.Activate;
|
||||
TQtWidget(hWnd).setFocus;
|
||||
{$ifdef VerboseFocus}
|
||||
DebugLn('********* TQtWidgetSet.SetFocus END was %x now is %x',[result,hwnd]);
|
||||
|
Loading…
Reference in New Issue
Block a user