How-to build a font sub-menu?

Klaus Major klaus at major-k.de
Fri Jun 6 09:07:00 EDT 2003


Hi Simon,

>
> On Wednesday, June 4, 2003, at 10:50 PM, Jeanne A. E. DeVoto wrote:
>>
>> You might want to take a look at "Recipe for populating a Text menu" 
>> in the
>> Cookbook.
>>
>
> Mmm, OK, where do I find it? There's a tutorial on using the Menu 
> Builder, but that doesn't talk about sub-menus.
> There's nothing that I can find on the runrev.com web site either.

Open the "Transcript Dictionary" -> Menu -> Help
Click on the btn "Roadmap2 in the lower right side of that window.
There click line "Transcript Cookbook" in that window.
Then choose from the menu "Show" the entry "Menus"

That's where you find the desired entry for building a "Font-Menu"

> I did find this link 
> (http://www.hyperactivesw.com/mctutorial/rraboutMenus.html) though, 
> which gave me some background on Revolution menus in general.
>
> Simon.

Unfortunately that does not cover your need of a sub menu (Just like
the "Text" menu in the RR menubar...)

But here is how to that that.

I use a generic button 1 in the script, please change it to  your 
needs...

on mouseup
   put the fontnames into fonz
   sort fonz
   ## here we are constructing the necessary list,
   ## we just will add a TAB in front of each line,
   ## since that's the way submenus are created :-)
   ## just check this script out and you will see...
   repeat for each line x in fonz
      put TAB & x & CR after subfonz
   end repeat
   delete char -1 of subfonz
   ## remove trailing empty line

  put "Font" & CR & subfonz into btn 1
end mouseup

We have to use another variable "subfonz", because
  the "repeat for each" loop is INCREDIBLY fast, really :-)
but is read-only.
Means we cannot change the value of x (in my example)
in the loop...

Now you will have to script that button to do your desired formatting...

Remember: to access the selected font in you need something like this:

on menupick which
   set the itemdel to "|"
   ## | = Alt-7 on a Mac, Alt-Gr-< on a PC
   ## the menu picked will be returned in this form: Font|Arial
   ## so we have to "extract" the actual fontname...
   ## ... now you can do everything you want with:
   ##   item -1 of which
...
end menupick


Hope this helps...

Have a nice weekend :-)


Regards

Klaus Major
klaus at major-k.de




More information about the use-livecode mailing list