Popup Menus

BlitzMax Modules Forums/Brucey's Modules/Popup Menus

Sample code:
Trying to establish which Listbox had the right click.

Main:
'
' Example application stub generated by wxCodeGen v0.96 : 25 Feb 2008 20:01:20
'
SuperStrict

Framework wx.wxApp

Import "TestPopups.bmx"
Import brl.filesystem
Import brl.system

New MyApp.run()

Type MyApp Extends wxApp

	Field frame:MyFrame2
	
	Method OnInit:Int()

?macos
		' make the default Mac font for controls not so big
		wxSystemOptions.SetOption(wxWINDOW_DEFAULT_VARIANT, wxWINDOW_VARIANT_SMALL)
?
		wxInitAllImageHandlers()

		wxImage.AddHandler( New wxXPMHandler ) ' for Mac/Win32 (it is default on Linux)

		Local frame:MyFrame2 = MyFrame2(New MyFrame2.Create(, , "Test Popup Menu Selection"))

		frame.show()
		
		SetTopWindow(frame)

		Return True
	End Method

End Type



Type MyFrame2 Extends MyFrame2Base

	Method OnInit()
		Super.OnInit()

		' Add own initialisation code here

	End Method

	Method RightClickForPopup(event:wxMouseEvent)
		' TODO : Implement me
		DebugLog "Right Click for Popup"
		
		
		
	End Method

End Type


Gui:
'
' BlitzMax code generated with wxCodeGen v0.96 : 25 Feb 2008 20:01:20
' 
' 
' PLEASE DO "NOT" EDIT THIS FILE!
' 
SuperStrict

Import wx.wxFrame
Import wx.wxListBox
Import wx.wxPanel
Import wx.wxWindow
Import wx.wxListCtrl

Type MyFrame2Base Extends wxFrame

	Field m_panel5:wxPanel
	Field m_listBoxPopup1:wxListBox
	Field m_listBoxPopup2:wxListBox
	Field m_listBoxNoPopup:wxListBox


	Method Create:MyFrame2Base(parent:wxWindow = Null,id:Int = wxID_ANY, title:String = "", x:Int = -1, y:Int = -1, w:Int = 500, h:Int = 300, style:Int = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL)
		Return MyFrame2Base(Super.Create(parent, id, title, x, y, w, h, style))
	End Method

	Method OnInit()

		Local bSizer11:wxBoxSizer
		bSizer11 = New wxBoxSizer.Create(wxVERTICAL)
		m_panel5 = New wxPanel.Create(Self, wxID_ANY,,,,, wxTAB_TRAVERSAL)

		Local bSizer12:wxBoxSizer
		bSizer12 = New wxBoxSizer.Create(wxVERTICAL)
		m_listBoxPopup1 = New wxListBox.Create(m_panel5, wxID_ANY, Null)

		bSizer12.Add(m_listBoxPopup1, 0, wxALL, 5)

		m_listBoxPopup2 = New wxListBox.Create(m_panel5, wxID_ANY, Null)

		bSizer12.Add(m_listBoxPopup2, 0, wxALL, 5)

		m_listBoxNoPopup = New wxListBox.Create(m_panel5, wxID_ANY, Null)

		bSizer12.Add(m_listBoxNoPopup, 0, wxALL, 5)

		m_panel5.SetSizer(bSizer12)
		m_panel5.Layout()
		bSizer11.Add(m_panel5, 1, wxEXPAND | wxALL, 5)

		SetSizer(bSizer11)
		Layout()

		m_listBoxPopup1.ConnectAny(wxEVT_RIGHT_UP, _RightClickForPopup, Null, Self)
		m_listBoxPopup2.ConnectAny(wxEVT_RIGHT_UP, _RightClickForPopup, Null, Self)
	End Method

	Function _RightClickForPopup(event:wxEvent)
		MyFrame2Base(event.sink).RightClickForPopup(wxMouseEvent(event))
		DebugStop
		Local s:Int = event.getid()'sink).RightClickForPopup.parent()
		DebugLog s
		Local a:Object = event.GetEventObject()
		DebugLog ""
	End Function

	Method RightClickForPopup(event:wxMouseEvent)
		DebugLog "Please override MyFrame2.RightClickForPopup()"
		event.Skip()
	End Method

End Type


The debug shows the first listbox as -203 (getid) and the second as -204. The third listbox is not responding to the right click (Intentional)

Stepping through the debug variables i can't identify these numbers.
Also object "a" doesn't mean much to me...

So each listbox is being identified uniquely but i don't know what the code means.

Cheers
Glenn