Creating a Font menu

Mark Talluto fuegox at mac.com
Mon Apr 29 01:20:01 EDT 2002


> Thanks Mark.
>     This is exactly what I was looking for.
>
> Now, how do you wire those menu items to actually do something?  Do you 
> have
> to dynamically create a huge script for that menu?
>
> I haven't been able to find a property that gets returned when you 
> select a
> particular font.  Surely there there's such a thing in Rev.
>
> Is there any kind of function that will determine what menu item you are
> coming from?  Let's say I have a text menu that displays font, size and
> style.  If I select a particular font in the font menu can I determine 
> I'm
> coming from the font menu are not some other?  If so, I could trap for 
> that
> menu item and create a much smaller routine to handle just fonts.
>
> Any advice out there would be greatly appreciated.
>
>
> Thanks!
>
>
> --
> Dave
> Retiarius Enterprises

Dave,

Here is a script that goes in the menubar button.  You will need to 
modify it a bit for your needs.  But, it should give you an idea where 
to go.



on MenuPick which
   global tstackname, numprobs, tcompareFont
   set the itemDel to "|"
   put item 2 of which into newatt

   --FIGURE OUT WHERE SIZE ENDS AND FONTS BEGIN
   --AND FIGURE OUT WHERE TO PUT THE CHECK MARKS
   --FOR BOTH SIZE AND FONT
   put the num of lines of button "text" into tLines
   repeat with y = 1 to tLines
     if line y of button "text" is "Fonts" then put y into tFontLine
     put line y of button "text" into tcompareFont
     if tcompareFont = newatt then put y into tcheckLine --check font 
sizes
     if y >= tFontLine then
       --check fonts
       set the itemdel to tab
       put item 2 of tcompareFont into tcompareFont
       if tcompareFont = newatt then put y into tcheckLine
     end if
   end repeat

   set the itemDel to "|"
   switch item 1 of which

   case "Size"
     --CLEAR CHECK MARKS
     repeat with y = 1 to (tFontLine-1)
       if char 1 of line y of button "text" is "!" then delete char 1 to 
2 of line y of button "text"
     end repeat

     put "!c" before line tcheckLine of button "text"--checks this line

     lock screen
     put the number of groups of stack tstackname into ngroups
     repeat with i = 2 to ngroups

       put the number of fields of group i of stack tstackname into 
nfields
       repeat with x = 1 to nfields
         put the number of lines of field x of group i of stack 
tstackname into tlines

         repeat with y = 1 to tlines
           set the effective textSize of line y of field x of group i of 
stack tstackname to newatt
           set the effective textheight of field x of group i of stack 
tstackname to (newatt+4)
         end repeat
       end repeat
     end repeat

     --RESIZE ALL THE GROUPS FOR MAXIMUM EFFECIENCY OF SPACE
     send mouseup to button "resizer" of card "worksheet" of stack 
tstackname
     unlock screen


     --REDO PROBLEM NUMBERS IF NEEDED TO REALIGN THEM
     if numprobs = "yes" then
       nonumprobs
       numprobs
     end if
     break




   case "Fonts"
     --CLEAR CHECK MARKS
     repeat with y = tFontLine to tLines
       if char 1 of line y of button "text" is "!" then delete char 1 to 
2 of line y of button "text"
     end repeat

     put "!c" before line tcheckLine of button "text"--checks this line

     lock screen

     put the number of groups of stack tstackname into ngroups
     repeat with i = 2 to ngroups
       put the number of lines of field 1 of group i of stack tstackname 
into tlines

       repeat with y = 1 to tlines
         set the effective textfont of line y of field 1 of group i of 
stack tstackname to newatt
       end repeat
     end repeat

     unlock screen
     break


   end switch
end MenuPick




More information about the use-livecode mailing list