Note that there are some explanatory texts on larger screens.

plurals
  1. PONot catching all mouse events with wxWidgets
    primarykey
    data
    text
    <p>Hi I am am trying to catch mouse movements for a MouseOver function in an app created with Code::Blocks using the wxSmith plugin. I have stumbled upon a puzzling problem. EVT_MOUSEWHEEL calling the function in the EventTable works well, but all other macros have no result at all. And the mousewheel is not <em>really</em> want I want (I just used it to test...) This is for Windows.</p> <p>Here is a the basic problem code (mostly generated by the <strong><em>fantastic</em></strong> wxSmith plugin) </p> <p>MouseMain.h</p> <pre><code>#include &lt;wx/frame.h&gt; #include &lt;wx/statusbr.h&gt; //*) class MouseFrame: public wxFrame { public: MouseFrame(wxWindow* parent,wxWindowID id = -1); virtual ~MouseFrame(); private: //(*Handlers(MouseFrame) void OnQuit(wxCommandEvent&amp; event); void OnAbout(wxCommandEvent&amp; event); void OnButton1Click(wxCommandEvent&amp; event); void MouseOver(wxMouseEvent&amp; event); //*) //(*Identifiers(MouseFrame) static const long ID_BUTTON1; static const long ID_STATICBITMAP1; static const long ID_PANEL1; static const long idMenuQuit; static const long idMenuAbout; static const long ID_STATUSBAR1; //*) //(*Declarations(MouseFrame) wxButton* Button1; wxStaticBitmap* StaticBitmap1; wxPanel* Panel1; wxStatusBar* StatusBar1; //*) DECLARE_EVENT_TABLE() }; #endif // MOUSEMAIN_H </code></pre> <p>...and MouseMain.cpp</p> <pre><code>#include "wx_pch.h" #include "MouseMain.h" #include &lt;wx/msgdlg.h&gt; //(*InternalHeaders(MouseFrame) #include &lt;wx/bitmap.h&gt; #include &lt;wx/intl.h&gt; #include &lt;wx/image.h&gt; #include &lt;wx/string.h&gt; //*) //helper functions enum wxbuildinfoformat { short_f, long_f }; wxString wxbuildinfo(wxbuildinfoformat format) { wxString wxbuild(wxVERSION_STRING); if (format == long_f ) { #if defined(__WXMSW__) wxbuild &lt;&lt; _T("-Windows"); #elif defined(__UNIX__) wxbuild &lt;&lt; _T("-Linux"); #endif #if wxUSE_UNICODE wxbuild &lt;&lt; _T("-Unicode build"); #else wxbuild &lt;&lt; _T("-ANSI build"); #endif // wxUSE_UNICODE } return wxbuild; } //(*IdInit(MouseFrame) const long MouseFrame::ID_BUTTON1 = wxNewId(); const long MouseFrame::ID_STATICBITMAP1 = wxNewId(); const long MouseFrame::ID_PANEL1 = wxNewId(); const long MouseFrame::idMenuQuit = wxNewId(); const long MouseFrame::idMenuAbout = wxNewId(); const long MouseFrame::ID_STATUSBAR1 = wxNewId(); //*) BEGIN_EVENT_TABLE(MouseFrame,wxFrame) EVT_RIGHT_DCLICK(MouseFrame::MouseOver) EVT_MOUSEWHEEL(MouseFrame::MouseOver) EVT_MOTION(MouseFrame::MouseOver) EVT_RIGHT_DOWN(MouseFrame::MouseOver) //(*EventTable(MouseFrame) //*) END_EVENT_TABLE() MouseFrame::MouseFrame(wxWindow* parent,wxWindowID id) { //(*Initialize(MouseFrame) wxMenuItem* MenuItem2; wxMenuItem* MenuItem1; wxMenu* Menu1; wxMenuBar* MenuBar1; wxFlexGridSizer* FlexGridSizer1; wxMenu* Menu2; Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id")); Panel1 = new wxPanel(this, ID_PANEL1, wxPoint(144,392), wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1")); FlexGridSizer1 = new wxFlexGridSizer(0, 3, 0, 0); Button1 = new wxButton(Panel1, ID_BUTTON1, _("TheButton"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1")); FlexGridSizer1-&gt;Add(Button1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); StaticBitmap1 = new wxStaticBitmap(Panel1, ID_STATICBITMAP1, wxNullBitmap, wxDefaultPosition, wxSize(159,189), wxSUNKEN_BORDER, _T("ID_STATICBITMAP1")); FlexGridSizer1-&gt;Add(StaticBitmap1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); Panel1-&gt;SetSizer(FlexGridSizer1); FlexGridSizer1-&gt;Fit(Panel1); FlexGridSizer1-&gt;SetSizeHints(Panel1); MenuBar1 = new wxMenuBar(); Menu1 = new wxMenu(); MenuItem1 = new wxMenuItem(Menu1, idMenuQuit, _("Quit\tAlt-F4"), _("Quit the application"), wxITEM_NORMAL); Menu1-&gt;Append(MenuItem1); MenuBar1-&gt;Append(Menu1, _("&amp;File")); Menu2 = new wxMenu(); MenuItem2 = new wxMenuItem(Menu2, idMenuAbout, _("About\tF1"), _("Show info about this application"), wxITEM_NORMAL); Menu2-&gt;Append(MenuItem2); MenuBar1-&gt;Append(Menu2, _("Help")); SetMenuBar(MenuBar1); StatusBar1 = new wxStatusBar(this, ID_STATUSBAR1, 0, _T("ID_STATUSBAR1")); int __wxStatusBarWidths_1[1] = { -1 }; int __wxStatusBarStyles_1[1] = { wxSB_NORMAL }; StatusBar1-&gt;SetFieldsCount(1,__wxStatusBarWidths_1); StatusBar1-&gt;SetStatusStyles(1,__wxStatusBarStyles_1); SetStatusBar(StatusBar1); Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&amp;MouseFrame::OnButton1Click); Connect(idMenuQuit,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&amp;MouseFrame::OnQuit); Connect(idMenuAbout,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&amp;MouseFrame::OnAbout); //*) } MouseFrame::~MouseFrame() { //(*Destroy(MouseFrame) //*) } void MouseFrame::OnQuit(wxCommandEvent&amp; event) { Close(); } void MouseFrame::OnAbout(wxCommandEvent&amp; event) { wxString msg = wxbuildinfo(long_f); wxMessageBox(msg, _("Welcome to...")); } void MouseFrame::OnButton1Click(wxCommandEvent&amp; event) { } void MouseFrame::MouseOver(wxMouseEvent&amp; event){ wxMessageBox(_("MouseOver event!")); } </code></pre> <p>MouseApp.h</p> <pre><code>#ifndef MOUSEAPP_H #define MOUSEAPP_H #include &lt;wx/app.h&gt; class MouseApp : public wxApp { public: virtual bool OnInit(); }; #endif // MOUSEAPP_H </code></pre> <p>So my big question: Why are EVT_MOTION, EVT_RIGHT_DOWN or EVT_RIGHT_DCLICK not calling MouseFrame::MouseOver(wxMouseEvent&amp; event) in the way EVT_MOUSEWHEEL does?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload