Page 1 of 1
menu builder help please
Posted: Thu Mar 26, 2015 8:44 pm
by jalz
Hi Guys,
I'm experimenting with the menu builder for my app. So far it looks straightforward even though I can't find much documentation on the tool. I've built a format menu with the following structure
Fonts
Typeface
Size
10
11
12
Style
Bold
Italic
Underline
My question is how do I get Typeface to display all the fonts on my system? I found some sample code and managed to populate an option menu called "cb_font" with all the fonts but can't get the top menu where I have the word typeface replaced with all the fonts. I'm calling this script on the open card handler as I read its best practice to load this menu up on startup.
createFontMenu
--Insert script for Font menu item here
get the fontNames ## list of installed fonts
sort lines of it
put it into button "Typeface"
--set the text of button "cb_font" to it
end createFontMenu
Many thanks as always
Jalz
Re: menu builder help please
Posted: Thu Mar 26, 2015 11:04 pm
by dunbarx
Hi.
The menuBuilder seems like a great tool, and it is. But it also is haunted.
Buttons are containers, and there is nothing special, particularly, about those buttons, except for certain properties> It is a stack property (the menuBar) that makes these grouped buttons act like a menu. You likely already know this.
Anyway, what you have started out to do should work fine. What are you seeing?
Craig Newman
Re: menu builder help please
Posted: Thu Mar 26, 2015 11:34 pm
by jalz
Hi Craig,
Thanks for your explanation regarding menus, buttons, containers. Yes I read this in some of the other posts and articles. I've got scripts executing from my format menu, but I'm still confused on how to populate a specific menu item. The menu I am trying to populate is Format. The menu Item is Font and a submenu called Typeface (which is what I want replaced with the fonts from the system).
The code I am using seems to be erroring with a "no such object" error on line - put it into button "Typeface"
I've tried putting it in "Font|Typeface" and "Font" for the button name to no avail.
I've added a sample file of the type of structure I am using
Jalz
Re: menu builder help please
Posted: Fri Mar 27, 2015 5:12 am
by dunbarx
I think I know what you are asking.
In a new stack, use the menu builder to create a new menu. Add another menu and name it "test". Make a new field and place this into it:
Code: Select all
Choice1/|1
Choice2/|2
choice2a/|3
choice3/|4
Choice4/|5
Choice5/|6
Choice6/|7
In the message box:
I believe that the code section will not copy correctly. Each "space" in the indented lines is in fact a tab. You may need to reconstruct this.
If you have trouble with the formatting, take this:
Code: Select all
Choice1/|1
XChoice2/|2
Xchoice2a/|3
choice3/|4
Choice4/|5
XChoice5/|6
Choice6/|7
Replace "X" with tab in the above text, and use that. Experiment with the tags that create submenus. Try to make three-level submenus.
Craig
Re: menu builder help please
Posted: Fri Mar 27, 2015 7:31 pm
by jalz
Thank you Craig,
Your instructions on new stack work bang on when I have a menu item (e.g. test). I'm trying to populate a submenu called "font", so I think all I need to get right is the button name of the submenu. How does the menu allocate names to containers that are 3 levels down. hope that makes sense?
All the best
Jalz
Re: menu builder help please
Posted: Fri Mar 27, 2015 8:03 pm
by dunbarx
Hi.
all I need to get right is the button name of the submenu.
There is only one button. It is the contents of that button, set up with the tab character and the tags "/" and "|" that create the hierarchy of menuItems and subMenuItems. I will still leave this to you as homework. Play with the "test" sample.
But in any case, to load the fonts, say, you should be able to pack the "item" of interest with that list, by careful parsing of the example.
Craig
Re: menu builder help please
Posted: Wed Nov 28, 2018 9:41 pm
by kaveh1000
Hi Craig
Great to see a trick to produce hierarchical menus. I get the multi-level menus but I am afraid I have failed the "homework" test and can't work out:
- How to get the menu item that I want in the selectedtext of the button – I am getting "Option/|1" etc as the selectedText
- I can see hierarchy in a Pulldown menu button but not in an Option menu
Any hints or pointers appreciated.
Kaveh
Re: menu builder help please
Posted: Thu Nov 29, 2018 4:20 am
by dunbarx
Hi.
There are differences between the four types of "menu" buttons, and not all of them support subMenus. The most straightforward is the pullDown. I would start there. Name it "B1"
Place the following into the text of btn "B1":
Code: Select all
Choice1/|1
Choice2/|2
Choice2a/|3
Choice3/|4
Choice4/|5
Choice5/|6
Choice6/|7
And then in the button script:
Code: Select all
on menuPick pItemName
answer pItemName
end menuPick
The contents of the button, which can be seen to be numbered, line by line, are denoted by the number after the "|". It is this value that matters.
Now select something from the pulldown. Note that in a hierarchal menuItem, you must select a submenu item, whereas in an "ordinary" menuItem (like "choice3") you can simply select the menuItem.
What you get back needs processing. If you select the subMenu "choice2a", you will get back "1|3". The "1" is the main menuItem, and the "3" is the line containing your actual choice. So you can, again in the button script:
Code: Select all
on menuPick pItemName
set the itemDel to "|"
put item 2 of pItemName into tLine
set the itemDel to "/"
answer item 1 of line tLine of me
end menuPick
Now this all can be simplified, which is another way of saying I am not sure I know what I am talking about. In that same button, load this from the message box:
Code: Select all
put "AA" & return & tab & "BB" & return & "CC" & return & "DD" into btn "btn1"
and this into its script:
Code: Select all
on menuPick PItemName
answer pItemName
end menuPick
You get the main menuItem, a "|" and the subMenuItem. You can extract the submenuItem as before.
Now add an extra tab:
Code: Select all
put "AA" & return & tab & "BB" & tab & "XX" & return & "CC" & return & "DD" into btn "btn1"
You do not get a second submenu to the menu "AA". You need those tags as set up as in the first example.
I think.
Experiment. That is what I do, and you also might look into the user guide, page 187 or so.
Craig
Re: menu builder help please
Posted: Thu Nov 29, 2018 3:32 pm
by kaveh1000
Thanks for taking the time, Craig. I am working on another part but will come back and use your excellent text here and report back.
