Bernie:
Right after I sent my previous post, I came
across the following from Robert Purves. posted
back in 2002.
Ken
/*
The preferences menu item in the OS X application menu
is system-supplied, not built by FB. All that the menu
preferences statement does is to enable that item with
EnableMenuCommand( 0, _"pref" )
The Preferences menu item thus has an ellipsis and no
Cmd-key, as in the OS X applications Mail, Image Capture,
Finder, Console, Sherlock, TextEdit, Stickies, iMovie...
i suspected that some default operation was in action here.
is there no way to provide a shortcut for this item?
Perhaps something like this might serve? It looks a bit
elaborate, but gives you full control and works in OS 8/9
or X, in Standard or Appearance.
Robert P.
*/
dim as short gPrefsMenuItem
_menuEdit = 2
end globals
/*
In OS 8/9, add a separator and Preferences item to the edit menu.
In OS X, enable the Preferences menu item and set its name and Cmd-key.
Pass 0 for cmdKey to have no Cmd-key equivalent.
*/
local mode
local fn AddPreferencesMenuItem( editMenuNum as short, ¬
prefsItemName as str255,¬
cmdKey as short )
'~'1
dim as short nEditMenuItems, prefsMenuItem
dim as MenuRef @ theMenu
dim as MenuItemIndex @ item
dim as OSStatus status
prefsMenuItem = 0
theMenu = fn GetMenuHandle( editMenuNum )
long if ( theMenu )
prefsMenuItem = fn CountMItems( theMenu ) + 2
long if ( system( _sysVers ) >= 1000 ) // OS X
#if CarbonLib
menu preferences editMenuNum, prefsMenuItem
status = fn GetIndMenuItemWithCommandID( 0, _kHICommandPreferences, ¬
1, @theMenu, @item )
long if ( status == _noErr )
long if ( cmdKey )
status = fn SetMenuItemCommandKey( theMenu, item, _false, cmdKey )
end if
SetMenuItemText( theMenu, item, prefsItemName )
end if
#endif
xelse // OS 8/9
menu editMenuNum, prefsMenuItem - 1, _disable, "-"
menu editMenuNum, prefsMenuItem, _enable, prefsItemName
if ( cmdKey ) then SetItemCmd( theMenu, prefsMenuItem, cmdKey )
end if
end if
end fn = prefsMenuItem
local fn HandleMenu
'~'1
if ( menu(0) == 1 ) then end
print menu(0), menu(1)
long if ( menu(0) == _menuEdit ) and ( menu(1) == gPrefsMenuItem )
print "Preferences item chosen"
end if
menu
end fn
on menu fn HandleMenu
menu 1, 0, _enable, "File"
menu 1, 1, _enable, "Quit/Q"
#if def _appearanceRuntime
gFBEditSelectAll = _zTrue
#endif
edit menu _menuEdit
gPrefsMenuItem = fn AddPreferencesMenuItem( _menuEdit, ¬
"Idiosyncratic Preferences", _";" )
print "Choose the Preferences menu item"
do
handleevents
until 0