Recent

Author Topic: TLabeledEdit: Incorrect component anchoring  (Read 3745 times)

zoltanleo

  • Hero Member
  • *****
  • Posts: 509
TLabeledEdit: Incorrect component anchoring
« on: April 11, 2019, 01:12:10 pm »
Hi all.

Looks like I found a bug. To the top side anchors LabeledEdit instead SubLabel. Try this code:
Code: Pascal  [Select][+][-]
  1. { TForm1 }
  2.  
  3. procedure TForm1.CheckBox1Change(Sender: TObject);
  4. begin
  5.   if CheckBox1.Checked
  6.     then LabeledEdit1.AnchorSideTop.Control:= Self
  7.     else LabeledEdit1.AnchorSideTop.Control:= nil;
  8. end;
  9.  
  10. procedure TForm1.FormCreate(Sender: TObject);
  11. begin
  12.   CheckBox1Change(Sender);
  13.   SpinEdit2Change(Sender);
  14. end;
  15.  
  16. procedure TForm1.SpinEdit2Change(Sender: TObject);
  17. begin
  18.   LabeledEdit1.BorderSpacing.Top:= SpinEdit2.Value;
  19. end;

Somebody make a ticket in the bugtracker pls, if I'm not mistaken.

ps. I use win7 x64/lazarus trunk/fpc trunk
Win10 LTSC x64/Deb 12 amd64(gtk2)/Kubuntu(qt5)/Darwin Cocoa x86_64 (Sequoia):
Lazarus x32_64 (trunk); FPC(trunk), FireBird 3.0.11; IBX by TonyW

Sorry for my bad English, I'm using translator ;)

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: TLabeledEdit: Incorrect component anchoring
« Reply #1 on: April 11, 2019, 06:59:57 pm »
That's because TLabeledEdit is derived from TCustomEdit and label is anchored to it. There is no simple solution. Similar twins - TEditButton, TDateEdit etc. - had the same problem in past but they were redesigned a few years ago. Now they are derived from TCustomControl and both Edit and Button are on placed it. Therefore anchoring works well there.
To solve this issue would be to redesign TLabeledEdit in similar way.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

zoltanleo

  • Hero Member
  • *****
  • Posts: 509
Re: TLabeledEdit: Incorrect component anchoring
« Reply #2 on: April 11, 2019, 08:27:57 pm »
To solve this issue would be to redesign TLabeledEdit in similar way.
So that's it.

Thank you for the clarification. Thus the component can't be used in production.
Win10 LTSC x64/Deb 12 amd64(gtk2)/Kubuntu(qt5)/Darwin Cocoa x86_64 (Sequoia):
Lazarus x32_64 (trunk); FPC(trunk), FireBird 3.0.11; IBX by TonyW

Sorry for my bad English, I'm using translator ;)

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: TLabeledEdit: Incorrect component anchoring
« Reply #3 on: April 11, 2019, 09:17:44 pm »
Thank you for the clarification. Thus the component can't be used in production.

It can. You just have to take into account its current limitations. Although it's a pity (and sometimes a PITA) that one can't use any of the control-layout options.
:(
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Bart

  • Hero Member
  • *****
  • Posts: 5649
    • Bart en Mariska's Webstek
Re: TLabeledEdit: Incorrect component anchoring
« Reply #4 on: April 11, 2019, 10:35:58 pm »
Maybe the ancestor of TEditButton can be modified so that the "buddy" component can also be above or below the Edit. Currently it only accepts controls left or right of it.

If that could be done, TLabeledEdit could easily be adapted and anchor correctly.

Bart

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: TLabeledEdit: Incorrect component anchoring
« Reply #5 on: April 11, 2019, 10:46:29 pm »
Maybe the ancestor of TEditButton can be modified so that the "buddy" component can also be above or below the Edit. Currently it only accepts controls left or right of it.

If that could be done, TLabeledEdit could easily be adapted and anchor correctly.

Currrently TLabeledEdit inherits from TCustomEdit; making it descend from TCustomAbstractGroupedEdit (as I think you mean) implies an almost complete redesign, as Blaazen said.

It should (probably) be done but it won't be done tomorrow :)

Backwards compatibility must be maintained, too, so maybe the best solution would be a new TEditLabel* control.


* To make it "rhyme" with TEditButton 8-)
« Last Edit: April 11, 2019, 11:01:04 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

mdalacu

  • Full Member
  • ***
  • Posts: 234
    • dmSimpleApps
Re: TLabeledEdit: Incorrect component anchoring
« Reply #6 on: January 09, 2023, 11:09:56 am »
Still the problem persist...3 years later. At least should e a mention in TObject inspector..or something like this. I have just lost 2h trying to see what i am doing wrong but no succes.

zoltanleo

  • Hero Member
  • *****
  • Posts: 509
Re: TLabeledEdit: Incorrect component anchoring
« Reply #7 on: January 09, 2023, 12:20:11 pm »
Hi mdalacu

I can give free advice. This means don't use this component. Use TEdit and TLabel instead  :)
Win10 LTSC x64/Deb 12 amd64(gtk2)/Kubuntu(qt5)/Darwin Cocoa x86_64 (Sequoia):
Lazarus x32_64 (trunk); FPC(trunk), FireBird 3.0.11; IBX by TonyW

Sorry for my bad English, I'm using translator ;)

mdalacu

  • Full Member
  • ***
  • Posts: 234
    • dmSimpleApps
Re: TLabeledEdit: Incorrect component anchoring
« Reply #8 on: January 10, 2023, 07:46:40 am »
Hi mdalacu

I can give free advice. This means don't use this component. Use TEdit and TLabel instead  :)
I know that but every edit box in my applications has an label attached to it. So this component is very convenient.
I would really like to make it reliable as it is included in standard components since ages ....

Bart

  • Hero Member
  • *****
  • Posts: 5649
    • Bart en Mariska's Webstek
Re: TLabeledEdit: Incorrect component anchoring
« Reply #9 on: January 10, 2023, 12:03:26 pm »
When changing it to behave like TEditButton, the control will no longer be Delphi compatible, and people will start complaining about that.
It's a lose, lose situation.

For now you can put each TLabeledEdit on a TPanel, and anchor the panel.
Not very convenient, though.

Bart

wp

  • Hero Member
  • *****
  • Posts: 13269
Re: TLabeledEdit: Incorrect component anchoring
« Reply #10 on: January 10, 2023, 12:39:53 pm »
the control will no longer be Delphi compatible
Our TLabeledEdit is NOT compatible with Delphi regarding this aspect:

Drop a panel on a form, drop a TLabeledEdit on the panel, set the panel's AutoSize to true. In Delphi the autoSized panel shows both label and edit, while in the LCL there is only the edit (which probably covers the label); there is excess space at the bottom indicating that the label has been considered for space calculation.
« Last Edit: January 10, 2023, 12:43:50 pm by wp »

mdalacu

  • Full Member
  • ***
  • Posts: 234
    • dmSimpleApps
Re: TLabeledEdit: Incorrect component anchoring
« Reply #11 on: January 10, 2023, 01:02:49 pm »
the control will no longer be Delphi compatible
Our TLabeledEdit is NOT compatible with Delphi regarding this aspect:

Drop a panel on a form, drop a TLabeledEdit on the panel, set the panel's AutoSize to true. In Delphi the autoSized panel shows both label and edit, while in the LCL there is only the edit (which probably covers the label); there is excess space at the bottom indicating that the label has been considered for space calculation.
Yes, this is the bug making vertical alignment impossible when depending on other controls.

Aistis

  • New Member
  • *
  • Posts: 28
    • Titbits of mind leakage
Re: TLabeledEdit: Incorrect component anchoring
« Reply #12 on: January 03, 2024, 11:30:59 am »
Still the problem persist...3 years later. At least should e a mention in TObject inspector..or something like this. I have just lost 2h trying to see what i am doing wrong but no succes.

I have also wasted 2 hours on this on Lazarus 3.0. I create most of my controls during runtime. When designing forms, the label at least shows up after the control is added to the form. But when it's added programmatically, the label is never visible unless a big enough left/top is used to unhide the label.

I double mdalacu and say that it should be at least mentioned in the docs. As it is now, it feels like it's personally mocking me  :D

Quote
"TLabeledEdit - It saves time an effort over placing separate Label and Edit Box on Form." - which you still need to do if you want it to actually work.

dsiders

  • Hero Member
  • *****
  • Posts: 1496
Re: TLabeledEdit: Incorrect component anchoring
« Reply #13 on: January 03, 2024, 05:27:52 pm »
Still the problem persist...3 years later. At least should e a mention in TObject inspector..or something like this. I have just lost 2h trying to see what i am doing wrong but no succes.

I have also wasted 2 hours on this on Lazarus 3.0. I create most of my controls during runtime. When designing forms, the label at least shows up after the control is added to the form. But when it's added programmatically, the label is never visible unless a big enough left/top is used to unhide the label.

I double mdalacu and say that it should be at least mentioned in the docs. As it is now, it feels like it's personally mocking me  :D

Quote
"TLabeledEdit - It saves time an effort over placing separate Label and Edit Box on Form." - which you still need to do if you want it to actually work.

And that has been done.

https://dsiders.gitlab.io/lazdocsnext/lcl/extctrls/tlabelededit.html

It's just not in the 3.0 release.
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

 

TinyPortal © 2005-2018