EventSource() and EVENT_GADGETMENU
BlitzMax Forums/BlitzMax Programming/EventSource() and EVENT_GADGETMENU
| ||
Hi all, I'm having trouble determining the source of Gadget Menu events. I have several right click menus I'd like to display depending on what gadget the user clicked on. I would have assumed that the Event Source would simply be the Gadget the user right-clicked on to produce this event ( as with other events such as EVENT_GADGETOPEN), but this seems not to be the case. Do I need to manually determine what the mouse was over at the time of the event or is there some bug here? Should also mention I'm working on Mac. There is another, perhaps related bug at the moment where the right-click menu appears at the bottom of the screen rather than under the pointer. |
| ||
OK, quick update. I moved the project to my PC system and confirmed that the behavior I expected is indeed how it works in Windows. That is, the EventSource() of right-clicking on a treeview = the treeview object. Can one of you admin guys move this tread to the Bugs forum?? Also note. On the mac, once you click on the menu the EventSource() of the event is the menuItem. On the PC this is not the case.. I can't work out what it is. I will try and write a small clear example later today. Jay. |
| ||
Here is the simple example' a window Local win:TGadget = CreateWindow("Project File Example",100,100,400,400,0,WINDOW_TITLEBAR|WINDOW_RESIZABLE|WINDOW_MENU|WINDOW_STATUS|WINDOW_CLIENTCOORDS|WINDOW_ACCEPTFILES) ' create a text area and treeview Local TextArea:tGadget = CreateTextArea ((ClientWidth(win)/2)+5, 0, (ClientWidth(win)/2)-10, ClientHeight(win), win) Local TreeView:tGadget = CreateTreeView (0,0,(ClientWidth(win)/2),ClientHeight(win),win) Local root:TGadget = TreeViewRoot(TreeView) Local tvHelp:TGadget = AddTreeViewNode("Help",root,1) Local tvHelp_t1:TGadget = AddTreeViewNode( "topic 1",tvhelp) Local tvHelp_t2:TGadget = AddTreeViewNode( "topic 2",tvhelp) Local tvHelp_t3:TGadget = AddTreeViewNode( "topic 3",tvhelp) ' a right click menu for the tree view Local TVMenu:tGadget = CreateMenu ("TVMENU",101,TreeView) Local TVMenu_Open:tGadget = CreateMenu ("Open Tree View", 102, TVMenu) Local TVMenu_Close:tGadget = CreateMenu ("Close Tree View", 103, TVMenu) ' a right click menu for the tree view Local TAMenu:tGadget = CreateMenu ("TAMENU",108,TextArea) Local TAMenu_Open:tGadget = CreateMenu ("Open Text Area", 109, TAMenu) Local TAMenu_Close:tGadget = CreateMenu ("Close Text Area", 110, TAMenu) ' Main loop While WaitEvent() Select EventID() Case EVENT_WINDOWCLOSE End Case EVENT_GADGETMENU Select EventSource() Case TreeView ' will not work on Mac. Works fine on PC <------------------------------------------ PopupWindowMenu (TreeView, TVMenu) Case TextArea PopupWindowMenu (TextArea, TAMenu) End Select Case EVENT_MENUACTION Select EventData() Case 101 Notify "TV Menu" Case 102 Notify "Open TV" Case 103 Notify "Close TV" Case 108 Notify "TA Menu" Case 109 ' here is a demo of event source for menu items If EventSource() = TAMenu_Open Then ' Will get this on MAC <---------------------------------------------------- Notify "TA Open: Source = This menu item" Else ' Will get this on PC <---------------------------------------------------- Notify "TA Open: Source = NOT this menu item" End If Case 110 Notify "TA CLose" End Select End Select Wend |
| ||
Was this filed as a bug? I got the same problem and it's a major showstopper for the Mac version of my program. |
| ||
This is no bug. At the moment, only the treeview emits that Event. Skid mentioned, that he plans to add _GadgetMenu and _GadgetSelect as well to the listbox, but others will never react to it. You would need to manually do something about it. I agree that ALL gadgets should react to all 3 events (as gadgetaction on most means doubleclick after the initial activation click) |
| ||
Yeah but. It works for the treeview in windows, but not on OS X? |
| ||
Perhaps a design decision? does it work if you use the regular key to "fake" rightclick on apple? (until recently the main system mouse was 1 button, not) |
| ||
Nope. The fake key does nothing at all :) It's rather inconsistent as it is and I have no way to tell which treeviewitem is under my cursor. |
| ||
why not? Doesn't SelectedTreeViewNode not give you the TGadget reference to the node? |