[futurebasic] Re: Hierarchical Prefs menu

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : August 2004 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Wed, 11 Aug 2004 10:37:04 -0400
Robert Covington asked:

>OS X:
>
>Menu Preferences seems to negate the possibility of a hierarchical
>prefs sub menu?
>
>I need a
>
>Preferences >
>
>Under the app menu, for sub pref panes accessed direct (per Photoshop
>7, etc)
>
>This possible given the way FB sets up the Prefs menu in the
>Application menu?



Robert,

Yes.

Now Compositor can look like PhotoShop.  ;-)

(You owe me big time. Scratched my head three 
days on this one, but in my heart, I knew it 
could be done! I was one happy puppy when I 
finally got it to work. Apple's documentation in 
some of this stuff is really poor. )

Ken

p.s. gnome: Glad to see you posting again. Hope 
all is well with you. I have a slight 
disagreement with you concerning preferences, I 
feel they should be readily accessible to users. 
But then again I'm a pilot and like to easy 
access to all my controls at a given time.

p.p.s. Usual disclaimer: Watch for e-mail line 
breaks and lost constant underscores on the 
Associate server (which is now ruined in its new 
format that no longer allows easy searching by 
date or list member's name. What a shame.)


/*

    Add sub menus to OS X Preference Menu Demo

    By Ken Shmidheiser
    Somerset, KY

    08-11-04

*/

toolbox fn SetMenuItemHierarchicalMenu ( MenuRef inMenu,¬
                                    MenuItemIndex inItem,¬
                                      MenuRef inHierMenu ) =  OSStatus

_prefsSubMenuID = 128

local fn CreateMenu( menuID as short,¬
          menuItems(9999) as str255,¬
                     nItems as short )
dim as MenuRef mRef
dim as long    j

mRef = fn NewMenu( menuID, "" )

long if mRef and ( nItems > 0 )
for j = 0 to nItems - 1
AppendMenu( mRef, menuItems(j) )
next
end if

end fn = mRef

local fn BuildPrefsSubMenu( menuID as short )
dim as str255 menuItems(20)
dim as long   j

j  = -1
j++ : menuItems(j) = "Preference Item 1"
j++ : menuItems(j) = "Preference Item 2"
j++ : menuItems(j) = "Preference Item 3"

end fn = fn CreateMenu( menuID, menuItems(0), j+1 )

local fn CreateOSXPrefsSubMenu

dim as OSStatus        err
dim as MenuRef       @ prefMenuRef, prefSubMenuRef
dim as MenuItemIndex @ prefIndex

_kInsertHierarchicalMenu = -1

prefSubMenuRef = fn BuildPrefsSubMenu( _prefsSubMenuID )

EnableMenuCommand( 0, _kHICommandPreferences)

err = fn GetIndMenuItemWithCommandID( _nil,¬
                  _kHICommandPreferences, 1,¬
                     prefMenuRef, prefIndex )
long if ( err == _noErr )
err = fn SetMenuItemHierarchicalMenu( prefMenuRef, prefIndex, prefSubMenuRef )
long if ( err == _noErr )
InsertMenu( prefMenuRef, _kInsertHierarchicalMenu )
end if
end if

end fn = err

local fn DoMenu
dim as long menuID, itemID

menuID = menu(_menuID)
itemID = menu(_itemID)

select case( menuID )
case _prefsSubMenuID
select( itemID )
case 1 : beep
case 2 : beep : delay 150 : beep
case 3 : beep : delay 150 : beep : delay 150 : beep
end select
end select

menu

end fn

on menu fn DoMenu

window 1

fn CreateOSXPrefsSubMenu

do
handleevents
until gFBQuit