FutureBasic Logo

<<    Index    >> FutureBasic 5

menu preferences   statement



Syntax:
menu preferences menuID, itemID

Description:
This command,  used in conjuction with other menu statements, moves the preference item to the standard MacOS X location in the Application menu. Prior to calling the  menu preference statement, a menu must be created with the preference item. When the menu preference statement executes, it not only moves the preference item to the Application menu but removes the preference item from the menu where it was created ( which is traditionally the edit menu but it could be a different menu ).  When the preference item is selected during program execution, the menu choice is converted to the specified menuID and itemID for use by the program. See the example below.

History:
Prior to OSX,  the preference menu item was located at the bottom of the Edit menu. In OSX, the preference menu item is located in the application menu. The Menu Preference statement was created to reduce coding and allow FutureBasic programmers to use the same menus in OS 9 and MacOS X without changing their FutureBasic source code.

Notes:

[1] The  itemID  must be the last item of the edit menu ( or wherever the preferences item is created ).
[2] This command assumes menus are created programmatically using either FB's Menu statement or toolbox calls. A menu bar and menus created as a Nib with Apple's Interface Builder does not need a Menu Preferences statement because the preference menu item is in the nib.

Example:

local fn DoMenu
    if ( menu
( _menuID ) == 2 and menu( _itemID ) == 10 ) then Print "Pref item selected"
end fn

apple menu
"About MyApp"

menu 1, 0, _enable,"File"

edit menu 2                            // Create Edit menu with standard copy, paste etc. items
menu 2, 10, _enable,"Preferences/,"    // Create Preference as item #10 to make sure it is last on the edit menu
menu preferences  2, 10                // Move item #10 from menu #2 ( preference item ) to the application menu

on menu fn DoMenu

do
    HandleEvents
until ( gFBQuit )



See Also:
put preferences; get preferences; kill preferences