How to set the font size and line spacing of menu items?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

How to set the font size and line spacing of menu items?

Post by sritcp » Sun Jun 24, 2012 10:01 pm

Is it even possible to set the text size of menu items of a pulldown menu (which is a button)?
Also, the vertical space between the menu items?

For mobile apps, the menu items need to be large enough and sufficiently separated from neighbor items to be tap-selected without error.

I couldn't find a way to manipulate the formatting of menu items.

Thanks for any light you can shed,
Sri.

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

Re: How to set the font size and line spacing of menu items?

Post by dunbarx » Mon Jun 25, 2012 4:10 pm

I believe that the font properties of the pulldown menuItems are set by the system. You can certainly set all text properties in the actual menuItem that is finally displayed. This is true for all the several button styles, like "popUp", "combo", etc.

If I am not wrong about this, you would have to roll your own pulldown, by showing a list field perhaps, and creating a mouseStillDown handler, also perhaps.

Is it that you want to display more lines within a given vertical area?

Craig Newman

sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: How to set the font size and line spacing of menu items?

Post by sritcp » Tue Jun 26, 2012 2:15 am

dunbarx wrote:...... You can certainly set all text properties in the actual menuItem that is finally displayed. ......
How exactly would I do that? It is not very clear from your post. Will a piece of code like

set the textSize of menuItem 1 of button "pullDownMenu" to 18

work? (the above code doesn't work; I guess because menuItem refers to the object itself not the text of its name).
Is it that you want to display more lines within a given vertical area?
No, I just want the menuItems to be more distantly spaced from each other (i.e., greater line height), so as to minimize the chances of tapping the item.

Regards,
Sri.

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

Re: How to set the font size and line spacing of menu items?

Post by dunbarx » Tue Jun 26, 2012 3:14 am

I see now what you want.

The textsize is a property of the button, not its menuItems, displayed or not. Likewise for every other text-like property. Try it either in the inspector or by script:

set the textsize of btn "yourPullDown" to 9. ( or 24)

Someone else may have an answer for you about increasing the line spacing. Is it possible for you to use a list field instead? There you can do what you want.

Craig Newman

sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: How to set the font size and line spacing of menu items?

Post by sritcp » Tue Jun 26, 2012 4:31 am

Unfortunately, increasing the textSize of the button (in the inspector or by script) increases only the label font size; the menuItems remain the same size.

Regards,
Sri.

mluka
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 73
Joined: Sun Jun 17, 2007 12:08 am
Location: Montréal, Canada

Re: How to set the font size and line spacing of menu items?

Post by mluka » Thu Sep 24, 2020 8:35 pm

Hi all. Sorry for "reviving" such an old post.

Has this question an answer, using LC 9.6.1, community edition?

In other words, is there any way of specifying the font, font size, style of the menu Item that has been chosen in a pulldown menu?

Thanks!
Michel
Montréal, Canada

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

Re: How to set the font size and line spacing of menu items?

Post by dunbarx » Thu Sep 24, 2020 9:10 pm

Mike.

Again, I am only fairly sure about the fact that the menuItems are controlled by the OS, though the label of the menuButton itself is controlled by you.

Nobody corrected me, so maybe that is in fact true.

I had suggested that it would be a snap to roll your own, in which you can control all aspects of the "menuItems" including line spacing. That also is still true. Do you need advice on how to do that?

Craig

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

Re: How to set the font size and line spacing of menu items?

Post by dunbarx » Thu Sep 24, 2020 9:45 pm

Hi.

Try this, five minutes. On a new card make a button and a listField. Turn off the vertical scrollbar in the field, and place it somewhere just below the button. Explicitly set the textHeight of the field to 13. In the button script:

Code: Select all

on mouseDown
   runKludge
end mouseDown

on runKludge
   show fld 1
   select line the (mouseV - top of fld 1) div 13 of fld 1
   
   if the mouse is up then
      answer the selectedText
      hide fld 1
      exit to top
   end if
   send "runKludge" to me in 10
end runKludge
If you modify a few properties in each control, you can readily make this pair indistinguishable from a standard pullDown. But you can also do whatever you want to with the text properties of the field.

Craig

mluka
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 73
Joined: Sun Jun 17, 2007 12:08 am
Location: Montréal, Canada

Re: How to set the font size and line spacing of menu items?

Post by mluka » Sat Sep 26, 2020 4:04 pm

Thanks Craig. That is one possible approach.

Would you care to comment on my latest post (regarding system fonts)?

viewtopic.php?f=7&t=34715

Regards.
Michel
Montréal, Canada

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

Re: How to set the font size and line spacing of menu items?

Post by FourthWorld » Sat Sep 26, 2020 8:00 pm

By default, LC uses the OS-recommended font and size for pulldown menus. With something this well established, I would encourage caution creating an app that deviates from such long-standing user expectations.

That said, on Windows and Linux, pulldown menus in the menu bar can be adjusted by changing the textfont and textsize properties.

MacOS uses a global menu bar, strictly governed by the OS do such modification is far less simple, requiring digging into OS menu definition hooks via LiveCode Builder.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”