View Issue Details

IDProjectCategoryView StatusLast Update
0034018LazarusLCLpublic2018-12-26 14:42
ReporterZeljan Rikalo Assigned ToMichl  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.9 (SVN) 
Summary0034018: LCL: Regression from r58448 & r58497
DescriptionNow: Disable control in designer (eg. groupbox with one TEdit inside it).
Under gtk2 and qt/qt5 control is enabled (and all of it's children).

When added WS_DISABLE into account (qt4) TGroupBox is disabled in runtime and that's fine, but when TGroupBox.Enabled := True during runtime, TEdit inside TGroupBox is still disabled (so something isn't processed to the children).
Win32 works ok in this case, but all others not. Please revert r58448 and r58497 or fix other widgetsets to work correctly.
Tested with trunk 1.9 r58594, Qt4 fpc-3.0.4 64bit.
TagsNo tags attached.
Fixed in Revision58684, 58735, 58740, 58758, 58759, 58764, 58782, 58912
LazTarget-
WidgetsetGTK 2, GTK 3, Carbon, Cocoa, QT, QT5
Attached Files

Relationships

related to 0033705 resolvedMichl Program starts slowly 
related to 0033923 closedMichl Behavior of EnableWindow since last MS Upgrades 
related to 0034763 resolvedMichl Regression: not every TGrouBox child follows parent's "Enabled" property. 

Activities

Zeljan Rikalo

2018-07-22 10:32

developer   ~0109620

@Michl, I've assigned this to you since you're author of those commits.

Zeljan Rikalo

2018-07-22 10:54

developer   ~0109625

This is possible patch for qt/qt5 if mentioned revisions
in TQtWidget.InitializeWidget ... after or before checking for WS_VISIBLE.
Note that LCLObject.Enabled property must be used to get correct result.

  if Assigned(LCLObject) then
    QWidget_setEnabled(Widget, LCLObject.Enabled)
  else
    QWidget_setEnabled(Widget, (FParams.Style and WS_DISABLED) = 0);

Zeljan Rikalo

2018-07-22 10:58

developer  

qt_qt5_34018.diff (1,177 bytes)   
Index: lcl/interfaces/qt/qtwidgets.pas
===================================================================
--- lcl/interfaces/qt/qtwidgets.pas	(revision 58591)
+++ lcl/interfaces/qt/qtwidgets.pas	(working copy)
@@ -2145,6 +2145,12 @@
 
   if Assigned(LCLObject) and FWidgetNeedFontColorInitialization then
     setInitialFontColor(LCLObject);
+
+  if Assigned(LCLObject) then
+    QWidget_setEnabled(Widget, LCLObject.Enabled)
+  else
+    QWidget_setEnabled(Widget, (FParams.Style and WS_DISABLED) = 0);
+
   if (FParams.Style and WS_VISIBLE) = 0 then
     QWidget_hide(Widget)
   else
Index: lcl/interfaces/qt5/qtwidgets.pas
===================================================================
--- lcl/interfaces/qt5/qtwidgets.pas	(revision 58591)
+++ lcl/interfaces/qt5/qtwidgets.pas	(working copy)
@@ -2149,6 +2149,12 @@
 
   if Assigned(LCLObject) and FWidgetNeedFontColorInitialization then
     setInitialFontColor(LCLObject);
+
+  if Assigned(LCLObject) then
+    QWidget_setEnabled(Widget, LCLObject.Enabled)
+  else
+    QWidget_setEnabled(Widget, (FParams.Style and WS_DISABLED) = 0);
+
   if (FParams.Style and WS_VISIBLE) = 0 then
     QWidget_hide(Widget)
   else
qt_qt5_34018.diff (1,177 bytes)   

Zeljan Rikalo

2018-07-22 10:58

developer   ~0109626

Attached patch for qt/qt5.

Zeljan Rikalo

2018-07-22 11:08

developer   ~0109627

Last edited: 2018-07-22 11:13

View 2 revisions

At the end, maybe we should keep r58448 & r58497 and fix others IMO.
EnableWindow uses Handle which could provoke Handle creation and that's why it's slower than usual. Patch for qt/qt5 is ready, gtk2 need to be fixed, or add LCL capability so no need for $IFDEF....call EnableWindow() if LCLCapability answer is no, otherwise use WS_DISABLED so widgetset can do it's job.
EDIT: EnableWindow() does not provoke Handle creation since it was called from InitializeWnd when handle is already created.

BrunoK

2018-07-23 10:41

reporter   ~0109640

Revision 58448 and 58497 and 0033923 bug.

These two patches should be reverted because they impact the behaviour of NON Windows UI / unconcerned WidgetSets.

58448 wincontrol.inc removal of
- if not (csDesigning in ComponentState) then

- EnableWindow(Handle, Enabled);

Causes your WidgetSet controls to NOT be notifeid of UI state setup after HANDLE creation.

58497 wincontrol.inc procedure TWinControl.CreateParams
addition
  if not IsEnabled then
    Params.Style := Params.Style or WS_DISABLED;
correctly sets HWNW.Enabled at creation but will not help for changes set via TWinControl.Enabled of embedded TWincontrol (Controls list property) when changing intermediate TWinControl.Enabled during the execution of the program.

Luiz Americo

2018-07-24 01:10

developer   ~0109642

I created a patch for gtk2. It's here: https://github.com/blikblum/lazarus-playground/commit/5e0a5719cbbaee3fcb2ad42d2d88e5828ca97d8f.diff

It's missing some controls but as soon as we settle in this approach i can complete it.

Also, when setting WS_DISABLED, Enabled should be used instead of IsEnabled since we want the individual enabled state and not the relative to parent. Patch here: https://github.com/blikblum/lazarus-playground/commit/1b5dcee493ffb209775988d46f138224a25e95f0.diff

With the second patch the Qt code could be simplified to QWidget_setEnabled(Widget, (FParams.Style and WS_DISABLED) = 0);

Michl

2018-08-18 09:08

developer   ~0110105

After the patch, for Qt and Qt5 it is the same behaviour as before r58448. Applied. Thank you!

Issue History

Date Modified Username Field Change
2018-07-22 10:31 Zeljan Rikalo New Issue
2018-07-22 10:32 Zeljan Rikalo Note Added: 0109620
2018-07-22 10:32 Zeljan Rikalo Assigned To => Zeljan Rikalo
2018-07-22 10:32 Zeljan Rikalo Status new => assigned
2018-07-22 10:33 Zeljan Rikalo Relationship added related to 0033705
2018-07-22 10:54 Zeljan Rikalo Note Added: 0109625
2018-07-22 10:58 Zeljan Rikalo File Added: qt_qt5_34018.diff
2018-07-22 10:58 Zeljan Rikalo Note Added: 0109626
2018-07-22 10:58 Zeljan Rikalo Assigned To Zeljan Rikalo => Michl
2018-07-22 11:08 Zeljan Rikalo Note Added: 0109627
2018-07-22 11:10 Zeljan Rikalo Relationship added related to 0033923
2018-07-22 11:13 Zeljan Rikalo Note Edited: 0109627 View Revisions
2018-07-23 10:41 BrunoK Note Added: 0109640
2018-07-24 01:10 Luiz Americo Note Added: 0109642
2018-08-18 09:08 Michl Fixed in Revision => 58684, 58735
2018-08-18 09:08 Michl Note Added: 0110105
2018-08-19 11:28 Michl Fixed in Revision 58684, 58735 => 58684, 58735, 58740
2018-08-22 22:19 Michl Fixed in Revision 58684, 58735, 58740 => 58684, 58735, 58740, 58758
2018-08-22 22:58 Michl Fixed in Revision 58684, 58735, 58740, 58758 => 58684, 58735, 58740, 58758, 58759
2018-08-22 22:58 Michl Status assigned => resolved
2018-08-22 22:58 Michl Resolution open => fixed
2018-09-08 22:03 Michl Fixed in Revision 58684, 58735, 58740, 58758, 58759 => 58684, 58735, 58740, 58758, 58759, 58764, 58782
2018-09-08 22:05 Michl Fixed in Revision 58684, 58735, 58740, 58758, 58759, 58764, 58782 => 58684, 58735, 58740, 58758, 58759, 58764, 58782, 58912
2018-10-14 17:17 Zeljan Rikalo Status resolved => closed
2018-12-26 14:42 Michl Relationship added related to 0034763