Lazarus

Programming => LCL => Topic started by: Muso on July 29, 2022, 08:14:56 pm

Title: [bug] anchor editor breaks visibility of LabeledEdit
Post by: Muso on July 29, 2022, 08:14:56 pm
The anchor editor (https://wiki.freepascal.org/Anchor_Sides) breaks for me the visiblity on LabeledEdits:
- take the attached simple Form
- select there the LabeledEdit and open the anchor editor
- enable the top anchor

result: the label is hidden under the panel

- to add space between the panel and the edit, add top border space

result: you can add as much space as you want and the label keeps invisible. The bug is that the space is added between the edit and the label and not between the LabeledEdit and the panel.
Title: Re: [bug] anchor editor breaks visibility of LabeledEdit
Post by: Bart on July 29, 2022, 09:08:36 pm
A TLabeledEdit cannot properly be alligned since the "alignment mechanism" only "sees" the TEdit part, so that one becomes aligned.
The same happens in Delphi.

Our TEditButton controls (basically a TEdit plus a TSpeedButton) don't have this problem since they are embedded in a TCustomControl, adn the TCustomControl gets aligned.
The drawback with that design is that you have to "forward" each and every property and method of the TEdit, whic is a lot of overhead.

If TLabeledEdit were redisigned like TEditButton, that the alignment problems would vanish.

Bart
Title: Re: [bug] anchor editor breaks visibility of LabeledEdit
Post by: Muso on August 01, 2022, 02:59:32 pm
A TLabeledEdit cannot properly be alligned since the "alignment mechanism" only "sees" the TEdit part, so that one becomes aligned.
The same happens in Delphi.
I understand, but why is the label part moved away from the edit part when I align?
I thought: "OK, the alignment only sees the edit part, so I add some space on top to make the label part visible". Instead the label part is then shifted upwards so that it stays invisible behind the object I want the LabeledEdit to be aligned below.
Title: Re: [bug] anchor editor breaks visibility of LabeledEdit
Post by: Bart on August 01, 2022, 09:55:34 pm
I have no idea.

Bart
Title: Re: [bug] anchor editor breaks visibility of LabeledEdit
Post by: jamie on August 01, 2022, 10:34:13 pm
Put the label Edit inside a TPanel..

Align the Panel instead and set the TLabelEdit for autosize etc.

Title: Re: [bug] anchor editor breaks visibility of LabeledEdit
Post by: Muso on August 04, 2022, 08:13:12 pm
Align the Panel instead and set the TLabelEdit for autosize etc.
Thanks.

However, I thought that the behaviour of TLabeledEditcould be improved somehow.
Title: Re: [bug] anchor editor breaks visibility of LabeledEdit
Post by: Bart on August 04, 2022, 10:17:05 pm
It can, in the way I described.
And then people will complain that it is not Delphi compatible anmore.

Bart
Title: Re: [bug] anchor editor breaks visibility of LabeledEdit
Post by: wp on August 05, 2022, 12:14:23 am
I don't understand jamie's description. Here's what I would do:
This can be applied to any combination of labels and controls (e.g. a "TLabeledCombobox")
Title: Re: [bug] anchor editor breaks visibility of LabeledEdit
Post by: HeavyUser on August 05, 2022, 12:34:01 am
I don't understand jamie's description. Here's what I would do:
  • Don't use TLabeledEdit.
  • Put the label and the edit into a panel.
  • Set the panel's ChildSizing.ControlsPerLine to 1, .EnlargeHorizontal to crsHomegenousChildResize and .Layout to cclLeftToRightThenTopToBottom.
  • Set the Panel's AutoSize to true and its Constraints.MinWidth to the desired width of the edit box.
This can be applied to any combination of labels and controls (e.g. a "TLabeledCombobox")
or make it a frame so you can drop as many as needed.
TinyPortal © 2005-2018