ive managed to use SetApplicationDockTileMenu (carbon) to add items to the dock tile, but i cant seem to find a way to receive the menu events..
anyone know how?
SetApplicationDockTileMenu [solved]
-
lexvictory
- Addict

- Posts: 1027
- Joined: Sun May 15, 2005 5:15 am
- Location: Australia
- Contact:
SetApplicationDockTileMenu [solved]
Last edited by lexvictory on Tue May 20, 2008 12:03 pm, edited 1 time in total.
Demonio Ardente
Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
As quoted in the Carbon Documentation
Source : http://developer.apple.com/documentatio ... ckTileMenuBefore the menu is displayed, it receives the Carbon events kEventMenuPopulate, kEventMenuOpening, and kEventMenuEnableItems, so any event handlers for these events can update the menu appropriately. You can receive notifications of and handle selections from the menu using kEventCommandProcess Carbon event handlers installed in the application event target.
-
lexvictory
- Addict

- Posts: 1027
- Joined: Sun May 15, 2005 5:15 am
- Location: Australia
- Contact:
-
lexvictory
- Addict

- Posts: 1027
- Joined: Sun May 15, 2005 5:15 am
- Location: Australia
- Contact:
ok, managed to dig around (used finder to search for things inside files)
and so ive finally got it working!
may be a bit rough around the edges, but here goes
pbl file:
and so ive finally got it working!
may be a bit rough around the edges, but here goes
Code: Select all
#noErr = 0
#kEventClassCommand = 'cmds'
#kEventCommandProcess = 1
#eventNotHandledErr = -9874;return when not our event
#kEventParamDirectObject = '----'
#typeHICommand = 'hcmd'
Structure EventTypeSpec
eventClass.l
eventKind.l
EndStructure
Structure menu
*menuRef
menuItemIndex.w
EndStructure
Structure HICommand
attributes.l
commandID.l
*menu
EndStructure
ProcedureDLL EventHandler(*nextHandler, theEvent, *userData)
;MessageRequester("Hello", "I got me a message!!!")
If geteventkind_(theEvent) = #kEventCommandProcess
GetEventParameter_(theEvent, #kEventParamDirectObject, #typeHICommand, #Null, SizeOf(HICommand), @size.l, @hicommand.HICommand)
Select hicommand\commandID
Case 1
Debug "menu item 1"
Default
Debug "menu item "+Str(hicommand\commandID)
EndSelect
EndIf
If *nexthandler
ProcedureReturn CallNextEventHandler_(*nextHandler, theEvent)
Else
ProcedureReturn #eventNotHandledErr
EndIf
EndProcedure
If OpenWindow(0, 100, 100, 195, 260, "PureBasic Window", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
CreatePopupMenu(0)
MenuItem(1, "test")
MenuItem(2, "test2")
MenuItem(50, "test 50")
setapplicationdocktilemenu_(MenuID(0))
functionupp = NewEventHandlerUPP_(@eventhandler())
eventTypes.EventTypeSpec\eventClass = #kEventClassCommand
eventtypes\eventKind = #kEventCommandProcess
InstallEventHandler_(GetApplicationEventTarget_(), functionupp, 1, @eventtypes, 0, @handlerref.l)
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_Event_CloseWindow ; If the user has pressed on the close button
Quit = 1
ElseIf eventid = #PB_Event_Menu
Debug "menu"
Select EventMenu()
Case #PB_Menu_Quit
Debug "got told to quit by dock or app menu"
Default
Debug EventMenu()
EndSelect
EndIf
Until Quit = 1
EndIfCode: Select all
;
-framework Carbon
GetApplicationDockTileMenu 0
SetApplicationDockTileMenu 1
OverlayApplicationDockTileImage 1
SetApplicationDockTileImage 1
RestoreApplicationDockTileImage 0
;InstallEventHandler 6
GetApplicationEventTarget 0
CallNextEventHandler 2
GetEventParameter 7
GetEventKind 1Demonio Ardente
Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!