On 10/27/2015 05:07 PM, Gabor Boros wrote:
2015.10.27. 16:16 keltezéssel, Zeljko írta:

csNoFocus does not work for Qt ? Can you provide example ?
For Qt: before example try to include qt4 and qtwidgets into your unit
and then
in CreateWnd of your custom form (or after form handle is created)

TQtMainWindow(YourForm.Handle).SetFocusPolicy(QtNoFocus);
TQtMainWindow(YourForm.Handle).WindowArea.SetFocusPolicy(QtNoFocus);

WindowArea not exist, found ScrollAera which is TQtWindowArea type.
But not have any effect for me. Example attached (without Qt and
WMNCHitTest trick).

Please test with attached patch and give feedback. Note that this patch is tested under Qt X11 only.

zeljko
Index: lcl/interfaces/qt/qtwidgets.pas
===================================================================
--- lcl/interfaces/qt/qtwidgets.pas	(revision 50180)
+++ lcl/interfaces/qt/qtwidgets.pas	(working copy)
@@ -4358,7 +4358,8 @@
 
 procedure TQtWidget.Activate;
 begin
-  QWidget_activateWindow(Widget);
+  if not testAttribute(QtWA_ShowWithoutActivating) then
+    QWidget_activateWindow(Widget);
 end;
 
 procedure TQtWidget.BringToFront;
Index: lcl/interfaces/qt/qtwsforms.pp
===================================================================
--- lcl/interfaces/qt/qtwsforms.pp	(revision 50180)
+++ lcl/interfaces/qt/qtwsforms.pp	(working copy)
@@ -923,6 +923,14 @@
 
   if not (csDesigning in AWidget.LCLObject.ComponentState) then
   begin
+    if (csNoFocus in TCustomForm(AWidget.LCLObject).ControlStyle) then
+    begin
+      {$IFDEF HASX11}
+      if csNoStdEvents in TCustomForm(AWidget.LCLObject).ControlStyle then
+        Flags := Flags or QtX11BypassWindowManagerHint;
+      {$ENDIF}
+      AWidget.setAttribute(QtWA_ShowWithoutActivating, True);
+    end;
     AWidget.setWindowFlags(Flags);
     if ABorderStyle in [bsDialog, bsNone, bsSingle] then
       AWidget.Resize(AWidget.LCLObject.Width, AWidget.LCLObject.Height)
--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to