Why does a button does look pressed when clicked over?

I looked some more into the problem. It seems related to the EVT_BUTTON event
and the event.Skip() but i still can't put my finger on the problem since the
behaviour it does not seem consistent with my code changes.

I wrote code that calls a methon when the putton is first pressed, then released
and also another method when you right click on it. The button has a tooltip.

Questions:
1) Must a button always have a handler for EVT_BUTTON if it has handlers for
EVT_LEFT_DOWN and EVT_LEFT_UP (and EVT_RIGHT_DOWN)?

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.

Thanks for the help!

Pierre

Pierre_Rouleau@ImpathNetworks.com on 05/28/2003 06:14:38 PM

Please respond to wxPython-users@lists.wxwindows.org

      over?

I am just starting with wxPython but already made a complete app in less than a
week. wxPython is *great*.
Thanks for the all the people that designed it and contribute!!

Question:

Is there any attribute to a wxButton or wxBitmapButton that can affect the
button behaviour and prevent it to look "pushed in" when the user left click on
it?

My app had button from day one and they looked fine. Then just today I realized
that the buttons dont push down anymore. The events are generated and the
methods are called, but the screen representation of the button does not change
when the user "presses" on the button.

I added a 'new' button to my app, and the new button works fine. Any idea?

I am using: wxPython 2.4.0.7, Python 2.2. Tried the app on Windows NT 4 SP6,
Windows 2000.

Many thanks,

Pierre

···

To: wxPython-users@lists.wxwindows.org
cc: (bcc: Pierre Rouleau/impath)
Subject: [wxPython-users] Why does a button does look pressed when clicked

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Pierre_Rouleau@ImpathNetworks.com wrote:

I looked some more into the problem. It seems related to the EVT_BUTTON event
and the event.Skip() but i still can't put my finger on the problem since the
behaviour it does not seem consistent with my code changes.

I wrote code that calls a methon when the putton is first pressed, then released
and also another method when you right click on it. The button has a tooltip.

Questions:
1) Must a button always have a handler for EVT_BUTTON if it has handlers for
EVT_LEFT_DOWN and EVT_LEFT_UP (and EVT_RIGHT_DOWN)?

No. Only if you want to attach a handler to EVT_BUTTON.

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?

···

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