I'm using wxWidgets 3.0.3 on Windows 8.1, with my IDE being Visual Studio 2017 Community.
I inherited from wxScrolled<wxWindow> to create EditWindow, which has the event myEVT_TILEHOVER declared and defined, along with EditWindowEvent which inherits from wxEvent, EditWindowEventFunction which is a typedef, EditWindowEventHandler which is a #define that uses wxEVENT_HANDLER_CAST, and EVT_TILEEDIT a #define that is used on the relevant frame's event table.
So it's on a frame, MyFrame, which inherits from wxFrame. The class function MyFrame::OnTileHover() is the one that is supposed to handle the event. The actual sender of the event is a PaletteWindow, which inherits from EditWindow.
On debugging it, I find that the internal function in EditWindow which handles the EVT_MOTION DOES get called properly, but upon calling wxPostEvent(), the MyFrame::OnTileHover() handler never gets called.
What am I doing wrong here? The project is attached. The event is supposed to be activated when you move the mouse over the PaletteWindow in the lower left part of the screen.
Event fails to call event function Topic is solved
Event fails to call event function
- Attachments
-
- sfcTileMapEditor.zip
- (14.63 KiB) Downloaded 75 times
Re: Event fails to call event function
I only took a quick glance at the code, my first guess would be: Derive EditWindowEvent from wxCommandEvent instead of wxEvent, because only those propagate upwards in the window hierarchy.
Use the source, Luke!
Re: Event fails to call event function
OK, got it, thanks!
BTW, if I use wxQueueEvent() instead of wxPostEvent(), it crashes. Why is this?
BTW, if I use wxQueueEvent() instead of wxPostEvent(), it crashes. Why is this?
Re: Event fails to call event function
Because wxQueueEvent expects a pointer to an event that was created on the heap and deletes it afterwards.BTW, if I use wxQueueEvent() instead of wxPostEvent(), it crashes. Why is this?
(As stated in the documentation...)
http://docs.wxwidgets.org/trunk/group__ ... d2c408bce1
Use the source, Luke!