Lazarus
Programming => LCL => Topic started 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.
-
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
-
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.
-
I have no idea.
Bart
-
Put the label Edit inside a TPanel..
Align the Panel instead and set the TLabelEdit for autosize etc.
-
Align the Panel instead and set the TLabelEdit for autosize etc.
Thanks.
However, I thought that the behaviour of TLabeledEditcould be improved somehow.
-
It can, in the way I described.
And then people will complain that it is not Delphi compatible anmore.
Bart
-
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")
-
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.