EventMenu - do not react as should be

Mac OSX specific forum
cajomi
User
User
Posts: 45
Joined: Thu Dec 04, 2008 9:53 am
Location: Essen

EventMenu - do not react as should be

Post 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
WilliamL
Addict
Addict
Posts: 1255
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Re: EventMenu - do not react as should be

Post 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  
MacBook Pro-M1 (2021), Tahoe 26.1, PB 6.30b2
cajomi
User
User
Posts: 45
Joined: Thu Dec 04, 2008 9:53 am
Location: Essen

Re: EventMenu - do not react as should be

Post 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
Post Reply