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:
zeljko 2010-10-08 07:36:15 +00:00
parent 68863ce1c3
commit ae23055240
2 changed files with 22 additions and 0 deletions

View File

@ -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:

View File

@ -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]);