WxWindow

From WxWiki

(Difference between revisions)
Jump to: navigation, search
Line 35: Line 35:
If you handle this event, as well as <code>EVT_RIGHT_DOWN</code> or <code>EVT_MIDDLE_DOWN</code>, and do not call <code>event.Skip()</code> you will most likely want to call <code>SetFocus()</code>. Failure to do so will prevent the window from receiving keyboard and mouse wheel events.
If you handle this event, as well as <code>EVT_RIGHT_DOWN</code> or <code>EVT_MIDDLE_DOWN</code>, and do not call <code>event.Skip()</code> you will most likely want to call <code>SetFocus()</code>. Failure to do so will prevent the window from receiving keyboard and mouse wheel events.
 +
 +
 +
== PushEventHandler() ==
 +
Don't forget to call RemoveEventHandler() or PopEventHandler() ''before deleting'' the object passed to PushEventHandler()
 +
 +
wxWidgets ''will not'' automatically cleanup the event handlers when you are closing the application. It will cause a number of weird segfaults when closing your application.

Revision as of 22:39, 10 December 2007

Contents

GetChildren

wxWindow::GetChildren() returns wxWindowList&, not wxList&. I got a warning at compile time when doing:

wxList& mylist = pWindow->GetChildren();

The warning was: [Warning] `operator 5' is deprecated (declared at C:/Dev-Cpp/include/wx-2.6/wx/list.h:1112)

Replacing wxList& with wxWindowList& fixed it.

RegisterHotKey

Eric Jensen writes on wx-users::

i was playing around with wxWindow::RegisterHotKey() and noticed that        
the virtualKeyCode parameter that this function uses, expects the           
Window keycodes and not the wxWidgets keycodes (e.g VK_F9 rather             
than WXK_F9).                                                              
                                                                            
Although this was not difficult to find, it should be mentioned in the       
documetation. However, if this function ever gets implemented on other     
platforms, using the 'normalized' wxWidgets keycode might become             
necessary.

EVT_WINDOW_CREATE

Your wxWindow-derived class will not receive this event if you create the window by calling the wxWindow constructor (as in MyWin::MyWin(wxWindow*parent) : wxWindow(parent,...)) because your object is still a wxWindow when the window is created. Call Create(parent,...) from the body of your constructor instead.

Also, don't try to receive EVT_WINDOW_DESTROY events in your own window, as is well documented in the official docs. Override Destroy() instead.

EVT_LEFT_DOWN

If you handle this event, as well as EVT_RIGHT_DOWN or EVT_MIDDLE_DOWN, and do not call event.Skip() you will most likely want to call SetFocus(). Failure to do so will prevent the window from receiving keyboard and mouse wheel events.


PushEventHandler()

Don't forget to call RemoveEventHandler() or PopEventHandler() before deleting the object passed to PushEventHandler()

wxWidgets will not automatically cleanup the event handlers when you are closing the application. It will cause a number of weird segfaults when closing your application.

Personal tools