Why does a button does look pressed when clicked over?

Note: title should be : Why does a button does NOT look pressed when clicked
over?

Robin Dunn wrote:

···

Pierre_Rouleau@ImpathNetworks.com wrote:

2) About event.Skip(). From my readings, you call event.Skip() inside
the
handler, to let the event be processed by the base wxWindow or the native
control. So it would seem that you should call event.Skip() for every
button
handler. Is this the case? The wxButton demo code does not call
Skip() for the
button event. I'm a little confused here.

It depends on the situation. For example, if an app catches EVT_BUTTON
and handles it, then there really isn't anything that the native control
needs to do with it. In fact in the case of EVT_BUTTON the wxButton
class and the native control don't do anything at all, wxWindows however
does try to continue finding a handler in the parent windows for
EVT_BUTTON.

On the other hand, in your situation, catching EVT_LEFT_DOWN for a
button and not calling Skip will prevent the native control from getting
the low level mouse event and therefore doing things like redrawing the
button in a pressed in state, and so forth. So in your case you
definitly want to call Skip for the DOWN and UP events so the native
control can do what it normally does for these events.

Make sense?

It does and that's why I am wondering why the demo code (wxButton) does not call
the event.Skip(). Is it because the button is inside a wxPanel in the demo?

(Sorry for the late reply, I was trying to post it through news.gmane.org but
for whatever reason, that post failed).

Thanks

--

Pierre Rouleau

Pierre_Rouleau@ImpathNetworks.com wrote:

It does and that's why I am wondering why the demo code (wxButton) does not call
the event.Skip(). Is it because the button is inside a wxPanel in the demo?

A button does nothing by default with a EVT_BUTTON event, it just generates it. (The same is true for most command events.) OTOH, the mouse events are *not* generated by the button, but are received from the platform and the button needs to use them to implement its normal functionality.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!