Page 1 of 1

How showing the current font in a popup menu SOLVED

Posted: Tue Jun 20, 2017 9:24 pm
by jmburnod
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

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

Posted: Tue Jun 20, 2017 10:42 pm
by bogs
I would guess your looking for (in the dictionary) either of the fontFileInUse, but it was a quick glance.

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

Posted: Wed Jun 21, 2017 2:49 am
by PBH
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

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

Posted: Wed Jun 21, 2017 2:42 pm
by jmburnod
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

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

Posted: Wed Jun 21, 2017 2:46 pm
by jmburnod
@ Bogs,
Thanks
But nothing for "fontFileInUse" in dictionary.
Where you found it ?
Best regards
Jean-Marc

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

Posted: Wed Jun 21, 2017 3:10 pm
by bogs
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 :(

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

Posted: Wed Jun 21, 2017 5:44 pm
by PBH
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

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

Posted: Wed Jun 21, 2017 6:19 pm
by jmburnod
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

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

Posted: Wed Jun 21, 2017 9:03 pm
by bogs
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:

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

Posted: Wed Jun 21, 2017 11:09 pm
by PBH
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

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

Posted: Thu Jun 22, 2017 4:57 pm
by tomBTG
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.

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

Posted: Thu Jun 22, 2017 5:20 pm
by mrcoollion
Maybe this post will help....

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

Regards,

Paul

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

Posted: Fri Jun 23, 2017 2:51 pm
by tomBTG
Nice! I'll give that a try.
Thanks,
Tom