This forgot contributing by the code that I wrote two years ago.
This is useful for multiusing two or more Window and two or more Gadget.
Target
SkinWin, double PopupDisplay
Code: Select all
Enumeration
#Window_0
#MenuBar_0
#MenuBar_1
#MENU_1
#MENU_2
#Editor_0
#Editor_1
EndEnumeration
Procedure GetMouse(Gadget)
GetCursorPos_(mouse.POINT)
MapWindowPoints_(0,GadgetID(Gadget),mouse,1)
x = mouse\x : y = mouse\y
xx = GadgetWidth(Gadget) : yy=GadgetHeight(Gadget)
If x >= 0 And x <= xx And y >= 0 And y <= yy
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
Procedure GetMouse2(Gadget)
GetCursorPos_(mouse.POINT)
MapWindowPoints_(0,WindowID(Gadget),mouse,1)
x = mouse\x : y = mouse\y
xx = WindowWidth(Gadget) : yy=WindowHeight(Gadget)
If x >= 0 And x <= xx And y >= 0 And y <= yy
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
Procedure Open_Window_0()
If OpenWindow(#Window_0, 216, 0, 449, 289, "New window ( 0 )", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreatePopupMenu(#MenuBar_0)
MenuItem(#MENU_1, "MENU")
EndIf
If CreatePopupMenu(#MenuBar_1)
MenuItem(#MENU_2, "SAVE")
EndIf
EditorGadget(#Editor_0, 10, 10, 220, 270)
EditorGadget(#Editor_1, 240, 10, 200, 270)
EndIf
EndProcedure
MessageRequester("Trouble", "This example cannot distinguish for which editor to show the popup for and can get them mixed up. ", #MB_OK|#MB_ICONINFORMATION)
Open_Window_0()
Repeat
Event = WaitWindowEvent() : WindowID = EventWindow()
GadgetID = EventGadget() :EventType = EventType()
If Event=#WM_RBUTTONDOWN
If GadgetID=#Editor_0
DisplayPopupMenu(#MenuBar_0, WindowID(#Window_0))
ElseIf GadgetID=#Editor_1
DisplayPopupMenu(#MenuBar_1, WindowID(#Window_0))
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
CloseWindow(#Window_0)
MessageRequester("This Tricks", "This example shows a different pop-up menu for each editor. ", #MB_OK|#MB_ICONINFORMATION)
Open_Window_0()
Repeat
Event = WaitWindowEvent() : WindowID = EventWindow()
GadgetID = EventGadget() :EventType = EventType()
If Event=#WM_RBUTTONDOWN
If GetMouse(#Editor_0)
DisplayPopupMenu(#MenuBar_0, WindowID(#Window_0))
ElseIf GetMouse(#Editor_1)
DisplayPopupMenu(#MenuBar_1, WindowID(#Window_0))
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
CloseWindow(#Window_0)
End