Recent

Author Topic: TSpeedButton adapt width to text  (Read 255 times)

domasz

  • Hero Member
  • *****
  • Posts: 553
TSpeedButton adapt width to text
« on: November 06, 2024, 09:40:45 am »
I have some TSpeedButtons with width = 90 px. I set captions, added glyphs, was great. But when translated to another language the text no longer fits.
I don't think the text can automatically wrap to more lines and center vertically so perhaps changing width to fit the text would be easy?
Any simple solution for that or do I have to measure text with Canvas.TextWidth and set Width accordingly?

Fibonacci

  • Hero Member
  • *****
  • Posts: 614
  • Internal Error Hunter
Re: TSpeedButton adapt width to text
« Reply #1 on: November 06, 2024, 09:43:43 am »
How about AutoSize?

domasz

  • Hero Member
  • *****
  • Posts: 553
Re: TSpeedButton adapt width to text
« Reply #2 on: November 06, 2024, 09:47:44 am »
Hahaha, I am stupid. Yes, thank you!

Fibonacci

  • Hero Member
  • *****
  • Posts: 614
  • Internal Error Hunter
Re: TSpeedButton adapt width to text
« Reply #3 on: November 06, 2024, 09:48:39 am »
:D

wp

  • Hero Member
  • *****
  • Posts: 12476
Re: TSpeedButton adapt width to text
« Reply #4 on: November 06, 2024, 10:55:37 am »
But you must be aware that when an auto-sized control can adjust its size to its caption it may overlap with the neighboring control, and this really looks uglyl. So, you either may choose a very loose layout, or you avoid the overlap by anchoring the controls to each other: https://wiki.freepascal.org/Anchor_Sides. Anchoring and autosizing are most effective to keep a layout intact, but you should know that then it is no longer possible to position or resize controls my means of the mouse.

 

TinyPortal © 2005-2018