BindMenuEvent()

Syntax

BindMenuEvent(#Menu, MenuItem, @Callback())
Description
Bind a menu event to a callback. A menu event can be unbinded with UnbindMenuEvent().

Parameters

#Menu The menu to bind the event to.
MenuItem The menu item within the menu to bind the event to.
@Callback() The callback procedure to call when the event occurs. It has to be declared like this:
  Procedure EventHandler()
    ; Code
  EndProcedure
Regular functions like EventGadget(), EventWindow(), EventMenu(), EventType() and EventData() are available within the callback to get more information about the event.

Return value

None.

Example

  Procedure TestHandler()
    Debug "Test menu event"
  EndProcedure
  
  Procedure QuitHandler()
    Debug "Quit menu event"
    End
  EndProcedure
  
  OpenWindow(0, 100, 100, 200, 50, "Click test", #PB_Window_SystemMenu)
  
  CreateMenu(0, WindowID(0))
    MenuTitle("File")
      MenuItem(0, "Test")
      MenuItem(1, "Quit")
  
  BindMenuEvent(0, 0, @TestHandler())
  BindMenuEvent(0, 1, @QuitHandler())

See Also

BindGadgetEvent(), BindMenuEvent(), UnbindEvent()

Supported OS

All

Menu Index - CloseSubMenu() ->