Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-02

How to query Enabled/Disabled component state?

5 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

Something weird I just noticed. I have not tested this under Delphi 7, but I have tested it with Lazarus GTK1 and GTK2 widget set. See attached image to help explain

If I do Panel1.Enabled = False, all components are disabled (visually). This is what I expected. But if I now query Edit1.Enabled, it returns True. Also if I query CheckBox2.Enabled it also returns True. Is this a bug?

For some reason I expected all child components to be Enabled = False, because that's what they are. Once Panel1 is disabled, I cannot set focus or interact with any child components. They are even painted in disabled state. How do I pragmatically detect if a component is "really" enabled or disabled? Seems that the logical way of quering the component's Enabled property gives false information.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sample.png
Type: image/png
Size: 1500 bytes
Desc: not available
Url : http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20090210/7fa9b146/attachment.png

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 17 lines
Hi, Something weird I just noticed. I have not tested this under Delphi 7, but I have tested it with Lazarus GTK1 and GTK2 widget set. See attached image to help explain If I do Panel1.Enabled = False, all components are disabled (visually). This is what I expected. But if I now query Edit1.Enabled, it returns True. Also if I query CheckBox2.Enabled it also returns True. Is this a bug? For some reason I expected all child components to be Enabled = False, because that's what they are. Once Panel1 is disabled, I cannot set focus or interact with any child components. They are even painted in disabled state. How do I pragmatically detect if a component is "really" enabled or disabled? Seems that the logical way of quering the component's Enabled property gives false information.

No, it gives the correct information.

You should use CanFocus for what you need.

Michael.

Reply by email

Graeme Geldenhuys
to Mattias Gärtner
Mattias G?rtner wrote 10 lines
Most LCL properties are relative. Left is relative to Parent, Visible hides all childs too, etc. As Michael said: Use CanFocus, which uses IsControlVisible and parent enabled. Use IsControlVisible to check whether a control is visible on the form. It checks parents and things like multi pages. It does not check whether the control is clipped. There are almost always exceptions to the rules. It depends on what you want to achieve.

OK, thanks.

Where is a good place to document this?

fpdoc documentation?

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email