]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/listbox/lboxtest.cpp
added wxListBox::HitTest() from Ryan (patch 1446207)
[wxWidgets.git] / samples / listbox / lboxtest.cpp
index 8f92c1920a46b2b74f9863058c72aadbdd618967..d2bbec8e791cf0c1110ddaad22039b25bf9ae6b1 100644 (file)
@@ -124,6 +124,7 @@ protected:
 
     void OnListbox(wxCommandEvent& event);
     void OnListboxDClick(wxCommandEvent& event);
+    void OnListboxRDown(wxMouseEvent& event);
 
     void OnCheckOrRadioBox(wxCommandEvent& event);
 
@@ -487,6 +488,9 @@ LboxTestFrame::LboxTestFrame(const wxString& title)
     m_logTarget = new LboxLogger(m_lboxLog, wxLog::GetActiveTarget());
     wxLog::SetActiveTarget(m_logTarget);
 #endif // wxUSE_LOG
+
+    m_lbox->Connect(wxEVT_RIGHT_DOWN, 
+        wxMouseEventHandler(LboxTestFrame::OnListboxRDown), NULL, this);
 }
 
 LboxTestFrame::~LboxTestFrame()
@@ -699,6 +703,18 @@ void LboxTestFrame::OnListboxDClick(wxCommandEvent& event)
     wxLogMessage(_T("Listbox item %d double clicked"), sel);
 }
 
+void LboxTestFrame::OnListboxRDown(wxMouseEvent& event)
+{
+    int item = m_lbox->HitTest(event.GetPosition());
+
+    if ( item != wxNOT_FOUND )
+        wxLogMessage(_T("Listbox item %d right clicked"), item);
+    else
+        wxLogMessage(_T("Listbox right clicked but no item clicked upon"));
+
+    event.Skip();
+}
+
 void LboxTestFrame::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
 {
     m_dirty = true;