How showing the current font in a popup menu SOLVED

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2350
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

How showing the current font in a popup menu SOLVED

Post by jmburnod » Tue Jun 20, 2017 9:24 pm

Hi All,
How showing the current font in a popup menu ?
I know how to set the checkmark, I want to see the current font at menu pick like mobilePick on iOS (the current font name appear on the middle of the list)
Best regards
Jean-Marc
Last edited by jmburnod on Wed Jun 21, 2017 6:30 pm, edited 1 time in total.

bogs
Posts: 3545
Joined: Sat Feb 25, 2017 10:45 pm

Re: How showing the current font in a popup menu ?

Post by bogs » Tue Jun 20, 2017 10:42 pm

I would guess your looking for (in the dictionary) either of the fontFileInUse, but it was a quick glance.
Image

PBH
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 95
Joined: Sun Feb 20, 2011 4:26 pm
Location: Vancouver Island, BC, Canada. ex.UK
Contact:

Re: How showing the current font in a popup menu ?

Post by PBH » Wed Jun 21, 2017 2:49 am

If I understand correctly, you'll need to set the menuHistory of the menu to the correct number. I tried an example and this works for me...

Field Script

Code: Select all

on selectionChanged
   put the text of btn "fontMenu" into tFontList -- Grabs the font list
   put the textFont of the selectedText into tSelectedTextFont -- Checks the font of the selected text
   put lineOffset(tSelectedTextFont,tFontList) into tLine -- Finds the line number of the selected text font from the font list
   set the menuHistory of btn "fontMenu" to tLine -- Sets the menuHistory (and the button label) of the font menu
end selectionChanged
I've added an attachment to show an example. You will see a single line version of the above code in the field script too.

Paul
Attachments
Font Selection.livecode.zip
menuHistory example
(7.67 KiB) Downloaded 62 times

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2350
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: How showing the current font in a popup menu ?

Post by jmburnod » Wed Jun 21, 2017 2:42 pm

Hi Paul,
Thanks for reply.
If I understand correctly
Yes.I'm very proud you understand my lemanic's english. It seems I progress :D
I found why current font doesn't appear in my stack.
I used a transparent button with a script to make a checkmark, not a popup
I think popup btn is a better way (the curfont name is hilited on menupick, checkmark is unuseful)
Jean-Marc

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2350
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: How showing the current font in a popup menu ?

Post by jmburnod » Wed Jun 21, 2017 2:46 pm

@ Bogs,
Thanks
But nothing for "fontFileInUse" in dictionary.
Where you found it ?
Best regards
Jean-Marc

bogs
Posts: 3545
Joined: Sat Feb 25, 2017 10:45 pm

Re: How showing the current font in a popup menu ?

Post by bogs » Wed Jun 21, 2017 3:10 pm

I am sorry Jean, usually I try to give more complete answers. I also belatedly realized that you've been using this language longer than I even knew it was around, outside of Hypercard :oops: so I'm not so sure at this point that it is what you were looking for, but here is the entry (Lc 6.5.4)
fontFilesInUse_Dictionary.png
fontFilesInUse entry in the Lc Dictionary
I completely missed 2 things, one it is desktop only, and 2 it is mac / windows only :roll:

Initially, I thought you were looking for the font in use by the system itself, but after re-reading the thread, probably not, sorry if I wasted your time :(
Image

PBH
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 95
Joined: Sun Feb 20, 2011 4:26 pm
Location: Vancouver Island, BC, Canada. ex.UK
Contact:

Re: How showing the current font in a popup menu ?

Post by PBH » Wed Jun 21, 2017 5:44 pm

Jean-Marc,

Your English is good, no worries there. :)

After another look at this I found the script I posted earlier will change the font to (Default) if the selection contains multiple fonts, so adding a condition improves the result.

This happens because setting the menuHistory triggers the menuPick handler in the font menu button, whereas just setting the label to "Mixed" doesn't trigger the menuPick handler.

Code: Select all

on selectionChanged
   put the text of btn "fontMenu" into tFontList
   put the textFont of the selectedText into tSelectedTextFont
   put lineOffset(tSelectedTextFont,tFontList) into tLine
   if tLine > 1 then
      set the menuHistory of btn "fontMenu" to tLine
   else
      set the label of btn "fontMenu" to "Mixed"
   end if
end selectionChanged
Of course this means the single line version is not recommended.

@Bogs - No need to apologise for making a suggestion and reaching out to help someone. It's good that people a willing to give up their time to help others.

Paul

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2350
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: How showing the current font in a popup menu ?

Post by jmburnod » Wed Jun 21, 2017 6:19 pm

Hi Paul,
I was wrong when I said I can use a popup btn. It doesn't work.
we have to use an option btn to do that
@ Bogs. What Paul said and If you know how many time some people "lost" for me...
I have again a large "debt" in this forum 8)

Edit: I works fine with menumode = option, not with menumode = PopUp

bogs
Posts: 3545
Joined: Sat Feb 25, 2017 10:45 pm

Re: How showing the current font in a popup menu SOLVED

Post by bogs » Wed Jun 21, 2017 9:03 pm

Phwew, I appreciate the understanding a LOT :mrgreen:
In the meantime, I will work on my reading comprehension skills and hopefully avoid similar in the future :wink:
Image

PBH
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 95
Joined: Sun Feb 20, 2011 4:26 pm
Location: Vancouver Island, BC, Canada. ex.UK
Contact:

Re: How showing the current font in a popup menu ?

Post by PBH » Wed Jun 21, 2017 11:09 pm

jmburnod wrote:works fine with menumode = option, not with menumode = PopUp
Unfortunately the menuHistory only works with the Option Menu, I can't find a way to make it work with the Pop-Up menu.

There maybe a way by using a stack as the pop-up, but unfortunately I don't have enough spare time to experiment this week, if I come up with a solution I'll let you know.

Paul

tomBTG
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 66
Joined: Fri Nov 25, 2011 6:42 pm
Location: Kansas City
Contact:

Re: How showing the current font in a popup menu SOLVED

Post by tomBTG » Thu Jun 22, 2017 4:57 pm

While we are on this subject, here's a challenge that has stumped me:

How to enhance font menus in standalones so the user can type a letter causing the list to jump to the first font name beginning with that letter?

Tom B.

mrcoollion
Posts: 396
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: How showing the current font in a popup menu SOLVED

Post by mrcoollion » Thu Jun 22, 2017 5:20 pm

Maybe this post will help....

Combo Box Filter Example
http://forums.livecode.com/viewtopic.php?f=70&t=17086

Regards,

Paul

tomBTG
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 66
Joined: Fri Nov 25, 2011 6:42 pm
Location: Kansas City
Contact:

Re: How showing the current font in a popup menu SOLVED

Post by tomBTG » Fri Jun 23, 2017 2:51 pm

Nice! I'll give that a try.
Thanks,
Tom

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”