Limiting the number of lines in menu buttons

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7589
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Limiting the number of lines in menu buttons

Post by dunbarx » Fri Mar 05, 2021 3:16 pm

I have found (LC 9.6.1, Mac OS 10.15.7) that the inspector option to limit the number of lines in a pulldown, popUp or option menu does nothing. If I have ten lines in the button, and set the "menuLines" property to 5,(either by hand or via the inspector) I still get all ten when I click on the button.

The dictionary states that this property only applies to option and combo styles, but in fact, of the four native styles, it applies only for combos.

The only way I can figure out how to limit the number of lines in the other three styles is to initially set a custom property, "the fullList", containing the full contents of the button, and then place this in the button script:

Code: Select all

on mouseDown
   if the optionKey is down then put line 1 to 5 of the fullList of me into me
   else put the fullList of me into me
end mouseDown
But this requires that the user to know to use the optionKey to limit the number of choices. It does, however, have the advantage that one can select any portion of the whole, which seems like a useful tool. And of course, one could always have set the contents of a menu Button under script control.

This is not the only place where the properties of certain menuButton styles are different from others.

But is the dictionary wrong about option menus, or, as usual, am I?

Craig
Last edited by dunbarx on Fri Mar 05, 2021 6:54 pm, edited 1 time in total.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 8551
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Limiting the number of lines in a menu buttons

Post by FourthWorld » Fri Mar 05, 2021 3:43 pm

Do you spend much time on Windows or Linux?

They often render option controls very differently from macOS.

It is that display difference, not the actual items available, that the menuLines governs. When the menuLines is less than the number of items, everything is still available but the menu will have a scrollbar.

The property has no effect on macOS because macOS always renders the list at a height showing all items without a scrollbar (up to the height of the display, of course; after that it still doesn't use scrollbars as Windows and Linux do, instead using an arrow to indicate more items are available).

On all platforms, if you don't want something available in a menu you'll have to remove it from the menu.
Richard Gaskin
LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7589
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Limiting the number of lines in menu buttons

Post by dunbarx » Fri Mar 05, 2021 3:51 pm

Richard.
When the menuLines is less than the number of items, everything is still available but the menu will have a scrollbar.
A scrollbar in the menuItem list?

Huh?

I am on a Mac. What else is there? 8)

Craig

PaulDaMacMan
Posts: 429
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: Limiting the number of lines in menu buttons

Post by PaulDaMacMan » Sun Mar 07, 2021 5:57 am

ComboBox menu type still honors the setting on macOS (10.14.6), menu does in fact have a scrollbar. I vaguely remember it having an affect on other menu types in earlier versions. Menus that autoscroll definitely do happen on the macOS if the menu has so many items that it can't fit the full list on the screen (I've populated menus with large lists).
Screen Shot 2021-03-06 at 11.52.27 PM.png
My LCB Repos: https://github.com/PaulMcClernan/
My LiveCode YouTube Videos: PlayList

Post Reply

Return to “Talking LiveCode”