How showing the current font in a popup menu SOLVED
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
How showing the current font in a popup menu SOLVED
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
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.
https://alternatic.ch
Re: How showing the current font in a popup menu ?
I would guess your looking for (in the dictionary) either of the fontFileInUse, but it was a quick glance.
-
- VIP Livecode Opensource Backer
- Posts: 129
- 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 ?
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
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
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
Paul
- Attachments
-
- Font Selection.livecode.zip
- menuHistory example
- (7.67 KiB) Downloaded 237 times
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: How showing the current font in a popup menu ?
Hi Paul,
Thanks for reply.
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
Thanks for reply.
Yes.I'm very proud you understand my lemanic's english. It seems I progressIf I understand correctly
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
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: How showing the current font in a popup menu ?
@ Bogs,
Thanks
But nothing for "fontFileInUse" in dictionary.
Where you found it ?
Best regards
Jean-Marc
Thanks
But nothing for "fontFileInUse" in dictionary.
Where you found it ?
Best regards
Jean-Marc
https://alternatic.ch
Re: How showing the current font in a popup menu ?
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 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)
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
I completely missed 2 things, one it is desktop only, and 2 it is mac / windows only 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
-
- VIP Livecode Opensource Backer
- Posts: 129
- 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 ?
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.
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
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
@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
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: How showing the current font in a popup menu ?
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
Edit: I works fine with menumode = option, not with menumode = PopUp
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
Edit: I works fine with menumode = option, not with menumode = PopUp
https://alternatic.ch
Re: How showing the current font in a popup menu SOLVED
Phwew, I appreciate the understanding a LOT
In the meantime, I will work on my reading comprehension skills and hopefully avoid similar in the future
In the meantime, I will work on my reading comprehension skills and hopefully avoid similar in the future
-
- VIP Livecode Opensource Backer
- Posts: 129
- 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 ?
Unfortunately the menuHistory only works with the Option Menu, I can't find a way to make it work with the Pop-Up menu.jmburnod wrote:works fine with menumode = option, not with menumode = PopUp
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
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.
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.
-
- Posts: 720
- Joined: Thu Sep 11, 2014 1:49 pm
- Location: The Netherlands
Re: How showing the current font in a popup menu SOLVED
Maybe this post will help....
Combo Box Filter Example
http://forums.livecode.com/viewtopic.php?f=70&t=17086
Regards,
Paul
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
Nice! I'll give that a try.
Thanks,
Tom
Thanks,
Tom