Recent

Author Topic: ComboBox height can't be made larger than 20 on intel Mac  (Read 5794 times)

Frogfather

  • Jr. Member
  • **
  • Posts: 55
ComboBox height can't be made larger than 20 on intel Mac
« on: October 29, 2023, 10:36:19 am »
Morning!

As the title says, I'm trying to adjust the height of a combo box either by altering the font size with auto size = true, manually by adjusting it on the form designer or programmatically by setting (e.g.) cb1.height:=30;

In all cases it doesn't seem possible to make the height larger than 20.

The text size does correspond to the font.height or font.size settings but as the actual control doesn't resize larger text is clipped by the bounds of the control.

MacBook pro 2018
MacOs Ventura 13.6
FPC 3.2.2
Lazarus: 2.2.6

Screenshot shows box with autosize off and font height = 36px

Joanna from IRC

  • Hero Member
  • *****
  • Posts: 1273
Re: ComboBox height can't be made larger than 20 on intel Mac
« Reply #1 on: October 29, 2023, 11:52:21 pm »
You might be able to use constraints to change the min and max height of the combobox
« Last Edit: October 30, 2023, 01:17:12 am by Joanna »
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

Frogfather

  • Jr. Member
  • **
  • Posts: 55
Re: ComboBox height can't be made larger than 20 on intel Mac
« Reply #2 on: October 30, 2023, 08:20:57 am »
Hi Joanna,

Thanks for the quick reply. Unfortunately that doesn't work and after a little investigation I see the same behaviour is exhibited by other similar controls (TEdit, TMaskEdit etc)

Here's the observed behaviour with constraints:

Set min width: control resizes (expected)
Set min width back to 0: control stays same size (expected)
Set min height to > 20: Control stays at 20 (oops)
Set max height to < 20: control resizes to new value (expected)
Set max height back to 0: control resizes to 20 (not expected)

Same behaviour with anchors - width resizes correctly but height doesn't.
Same behaviour programmatically setting height and width.
Same behaviour editing the lfm file.

I'll try with Windows and Linux later if I have time but suspect they'll work OK since if this was a common issue someone else would have noticed before now.

Btw I'm happy to investigate myself if someone can point me to the section of the codebase that handles resizing controls.

Cheers

John


Joanna from IRC

  • Hero Member
  • *****
  • Posts: 1273
Re: ComboBox height can't be made larger than 20 on intel Mac
« Reply #3 on: October 30, 2023, 12:04:46 pm »
Here is how I do it in my tcontrol helper, the code will work for many types of controls.
When the size of the text changes I call this procedure.
This might not be the best solution but it works for me  8)
Code: Pascal  [Select][+][-]
  1. PROCEDURE TCONTROL_HELPER.CONSTRAIN_HT( CONST AHEIGHT: INTEGER) ;
  2. BEGIN
  3. IF AHEIGHT < 0 THEN exit
  4. WITH Constraints DO
  5.      BEGIN
  6.      MinHeight := AHEIGHT;
  7.      MaxHeight := AHEIGHT;
  8.      END;
  9. Height:= AHEIGHT; // height is not guaranteed to change sometimes unless explicitly set.
  10. END;
  11.  
« Last Edit: October 30, 2023, 12:07:25 pm by Joanna »
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

Frogfather

  • Jr. Member
  • **
  • Posts: 55
Re: ComboBox height can't be made larger than 20 on intel Mac
« Reply #4 on: October 30, 2023, 10:00:56 pm »
Hi Joanna,

I've checked on a Windows machine and as I suspected the issue does not occur on Windows. I'll hazard a guess it's mac only but I haven't had time to try on either my m1 work machine or my Linux machine.

I don't know the details of how the ide communicates with the underlying apple widgets but it seems that any request to increase the height beyond 20 either by altering the setting in the object inspector or programmatically is simply ignored.

Thanks for your help anyway :)

Joanna from IRC

  • Hero Member
  • *****
  • Posts: 1273
Re: ComboBox height can't be made larger than 20 on intel Mac
« Reply #5 on: October 31, 2023, 12:03:36 pm »
You’re welcome. Good luck  ;)
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

Josh

  • Hero Member
  • *****
  • Posts: 1346
Re: ComboBox height can't be made larger than 20 on intel Mac
« Reply #6 on: October 31, 2023, 02:08:29 pm »
on cocoa, various controls including tcombobox are fixed by the OS, its not a flaw of lazarus, but 'features' of the os native widgetset.

If your needing your UI to be the same on all platforms you support, then its best to use controls that are custom controls and non reliant on the native widgetset your targetting..


https://wiki.freepascal.org/Cocoa_Internals/Text_Controls

Its worth remembering that controls may have properties that are not supported on various OS's, indeed lazarus does inform you of these if you click the restriction tab for whichever control you editing.

The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Frogfather

  • Jr. Member
  • **
  • Posts: 55
Re: ComboBox height can't be made larger than 20 on intel Mac
« Reply #7 on: November 02, 2023, 07:57:29 pm »
Hi Josh

Aha! I didn't see that restricted tab because it's not visible unless the object inspector is made quite wide.

Cheers

John

wp

  • Hero Member
  • *****
  • Posts: 12523
Re: ComboBox height can't be made larger than 20 on intel Mac
« Reply #8 on: November 02, 2023, 11:36:25 pm »
There is also a "Restriction Browser" in the "View" menu with a bit more text.

 

TinyPortal © 2005-2018