Menu popups on right mouse button
BlitzMax Forums/BlitzMax Beginners Area/Menu popups on right mouse button
| ||
Is it possible to have a popup menu when I am pressing the right mouse button on some area of one canvas gadget? (MaxGui). Thank you :) |
| ||
Yes you can, here is a quick example: |
| ||
Hmmm , for all of this code the crucial function is PopupWindowMenu(). As I understand , I will create another one menu on my main window which will be invisible It worked , I created one little popup menu when you press right mouse on the map. Hmm nice. The code above is very complex. I created one little code which I translate all mouse variables to only 3 variables pointer_x , pointer_y and pointer_b If EventID() = EVENT_MOUSEMOVE Then If EventSource() = graphics_canvas pointer_x = EventX() pointer_y = EventY() Endif Endif If EventID() = EVENT_MOUSEDOWN Then If EventData()=1 Then pointer_b=1 If EventData()=2 Then pointer_b=2 If EventData()=3 Then pointer_b=3 If pointer_b=2 then PopupWindowMenu(main_window,map_popup_menu) Endif Endif Menu Creation code map_popup_menu = CreateMenu("",0,Null) Global POPUP_EDIT:TGadget = CreateMenu("Edit", 1, map_popup_menu) When I am pressing my right mouse button in any area I have popup menu. When you select your menu you have to put one pointer_b=0 and return For example if I want to have a specific area on my main canvas. If EventID() = EVENT_GADGETPAINT Then If EventSource() = graphics_canvas SetGraphics CanvasGraphics(graphics_canvas) SetViewport 0, 0, GadgetWidth(graphics_canvas), GadgetHeight(graphics_canvas) Draw_Map_Panel() RedrawGadget(graphics_canvas) EndIf Endif Somewhere in the Draw_Map_Panel() function Function Draw_Map_Panel( . . . 'The area I want the popup menu appear only (My Map) If pointer_x >= 15 And pointer_x <= 590 And pointer_y >= 85 And pointer_y <= 444 And tools.wall_selected=1 Then If pointer_b=2 Then PopupWindowMenu(main_window,map_popup_menu) pointer_b=0 Return End If Endif End Function Might you don't understand my code , but it worked perfect. Thank very very much for your example. Last edited 2012 |