Page 1 of 1

EventMenu - do not react as should be

Posted: Mon Dec 13, 2010 1:04 pm
by cajomi
I have many problems with the EventMenu:

Menuitem - not recognize, if their is am even the from the main menu

Menuitem - recognize, if their is am event from popup menu, but don`t recognize the first event, if their is a second event with the equal number (same menu item, with different numbers)

I hope, that is clear enough, else I make clearer.

Johannes

Re: EventMenu - do not react as should be

Posted: Mon Dec 13, 2010 6:24 pm
by WilliamL
Maybe if the CreatePopupMenu() and CreateMenu() are different numbers and the MenuItems are all exclusive. Of course, you will have to check two numbers in the event loop for each duplicated menu (for example Cut will be #1 and #7)

Code: Select all

If CreatePopupMenu(0)
  MenuItem(1, "Cut")
  MenuItem(2, "Copy")
  MenuItem(3, "Paste")
  MenuBar()
  OpenSubMenu("Options")
    MenuItem(4, "Window...")
    MenuItem(5, "Gadget...")
  CloseSubMenu()
  MenuBar()
  MenuItem( 6, "Quit")
EndIf

If OpenWindow(0, 100, 100, 300, 260, "PureBasic - PopupMenu Example")
   If CreateMenu(1, WindowID(0))
      MenuTitle("Options")
      MenuItem( 7, "Cut")
      MenuItem( 8, "Copy")
  EndIf
  ListIconGadget(0, 10, 10, 280, 240, "Tools", 200)
    AddGadgetItem(0, -1, "Hammer")
    AddGadgetItem(0, -1, "Gadget...")

  Repeat
    Select WaitWindowEvent() 
      Case #PB_Event_Gadget
        If EventGadget() = 0 And EventType() = #PB_EventType_RightClick
          DisplayPopupMenu(0, WindowID(0))
        EndIf
      Case #PB_Event_Menu
        Select EventMenu()  ; To see which menu has been selected
          Case 1,7 ; Cut
            MessageRequester("PureBasic", "Cut", 0)
          Case 2,8 ; Copy
            MessageRequester("PureBasic", "Copy", 0)
          Case 3 ; Paste
            MessageRequester("PureBasic", "Paste", 0)
          Case 6 ; Quit
            Quit = 1
        EndSelect
      Case #PB_Event_CloseWindow
        Quit = 1
    EndSelect
  Until Quit = 1
EndIf

End  

Re: EventMenu - do not react as should be

Posted: Tue Dec 14, 2010 9:59 am
by cajomi
When I disabled all gadget, only the first not, I can see it.

Just a few days in holidays, when I am back, I post it

Johannes