Standalone and "About..." menu

Richard Gaskin ambassador at fourthworld.com
Mon Oct 25 09:36:50 EDT 2010


René Micout wrote:

> When I create a standalone, LiveCode make automatically an "About..." menu in the application menubar...
> How can I pick this menu item ?
> on menuPick theItem
> 	if theItem is "About..." then
> 	...
> end mousePick
> don't work

The LiveCode engine makes it very easy to create menu sets that 
substantially conform to the HIGs on supported platforms, but difficult 
to do anything non-standard.

In most apps, there is a "Preferences..." it at the end of the Edit 
menu, and an "About..." item at the end of the Help menu.

That is, for Windows and Linux - on OS X the "About..." item appears 
next to that OS's unique application menu, and the "Preferences..." item 
is the second entry in that menu.

To allow you to make one menu bar that works on all supported platforms, 
the engine moves the last item from the Help menu (presumed to be 
"About...") and the last item from the Edit menu (presumed to be 
"Preferences...") to their appropriate place in the application menu on 
OS X; it leaves them in place for other OSes.

While your item may be named "Preferences..." (with three periods), once 
rendered by the OS it becomes rendered as "Preferences…" (with an 
ellipsis), and is identified internally as the argument to the menuPick 
message as simply "Preferences".   Oddly, this does not happen with the 
About item, which is identified in the menuPick argument as you had 
typed it.

So in your menuPick handler for Help you'll want:

on menuPick pItem
     case "About..."
       answer "My Cool App"&cr& "Copyright 2010 by me"
       break
     case "Other Menu Items"
       -- do stuff for those
     break
     end switch
end menuPick

But in Edit you'll need:

on menuPick pItem
   case "Preferences"  -- for OS X
   case "Preferences..."  -- for everything else
     -- do prefs stuff
   break
   end switch
end menuPick

I tried to post a bug report on that, but got an error in Bugzilla. ;) 
I'll try again later.


IIRC the Rev IDE used to automatically write appropriate case statements 
for items you build with its Menu Builder utility, but checking this 
just now it seems it no longer does, writing only one generic menuPick 
handler with no individual case statements in it, so you're on your own.

It's also worth noting that the current LiveCode IDE does not write the 
names of the "About..." and "Preferences..." items with the trailing 
periods or even an ellipsis, so while the engine will at least render 
the Prefs item correctly on OS X it doesn't render About or Prefs 
correctly for other platforms.

Perhaps someone who uses the LC IDE might consider flagging that as a bug.

Here I've found it simpler to just roll my own menu bar, copying it into 
stacks and adjusting its items as needed.  Your mileage may vary; 
contents may settle during shipping; items in mirror may be closer than 
they appear.

IMNSHO, most of the complaints about making menu bars in Rev would go 
away if this small handful of inconsistencies was addressed.  The 
mechanism itself is fairly robust and does a good job of automatically 
handling differences between OSes, but is made to appear more 
complicated than it needs to be by these anomalies.

--
  Richard Gaskin
  Fourth World
  LiveCode training and consulting: http://www.fourthworld.com
  Webzine for LiveCode developers: http://www.LiveCodeJournal.com
  LiveCode Journal blog: http://LiveCodejournal.com/blog.irv



More information about the use-livecode mailing list