EVT_ENTER_WINDOW doesn't always work?

Hi,

I'm trying to respond to mouse enter/leave events on a wxStaticBitmap, but they don't seem to be generated.

Registering a handler for EVT_MOUSE_EVENTS shows that (eg.) motion and click events are being generated, but not enter/leave.

Querying event.Entering() or event.Leaving() inside the handler always gets zero-values.

So I guess my question is how can I find when the mouse enters and leaves the wxStaticBitmap, or is it impossible?

If it's not possible with this widget, are there other (container) widgets that would work?

(Oh, EVT_ENTER_WINDOW works as documented for the main wxFrame...)

Cheers,
Rob

Robin Stevens wrote:

Hi,

I'm trying to respond to mouse enter/leave events on a wxStaticBitmap, but they don't seem to be generated.

Registering a handler for EVT_MOUSE_EVENTS shows that (eg.) motion and click events are being generated, but not enter/leave.

Querying event.Entering() or event.Leaving() inside the handler always gets zero-values.

So I guess my question is how can I find when the mouse enters and leaves the wxStaticBitmap, or is it impossible?

If it's not possible with this widget, are there other (container) widgets that would work?

Platform and version? If not MSW then it's not too surprising as some native widgets are not true windows, and so they don't generate all the low level events you might expect.

It should be easy to make your own widget that is a true window and draws a bitmap on itself. For an example take a look at wxPython/lib/buttons.py or stattext.py/

···

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

Robin Dunn wrote:

Robin Stevens wrote:

<snip>

Registering a handler for EVT_MOUSE_EVENTS shows that (eg.) motion and click events are being generated, but not enter/leave.

<snip>

Platform and version?

Sorry! It's linux (debian), python 2.2.3, wxPython 2.4.0.7

If not MSW then it's not too surprising as some native widgets are not true windows, and so they don't generate all the low level events you might expect.

Aah, well it'll be wxGTK (using GTK2.0 I think...) so that explains that.

It should be easy to make your own widget that is a true window and draws a bitmap on itself. For an example take a look at wxPython/lib/buttons.py or stattext.py/

I was using wxStaticBitmap, I'm now using rStaticBitmap which inherits a wxWindow and contains (you guessed it) a wxStaticBitmap.

This works perfectly :slight_smile:

Thanks for your help Robin.

BTW (and probably off-topic) doesn't this platform-dependency go somewhat against the spirit of wxWindows? If it's such a trivial excercise (as I've now discovered) to embed one widget in a proper window why doesn't the wxGTK use such techniques to mimic the wxMSW one. (Arbitrary choice of wxGTK/wxMSW there, I have no preference for MSW :wink:
Or has this subject been debated to death elsewhere?

Cheers,
Robin

Robin Stevens wrote:

BTW (and probably off-topic) doesn't this platform-dependency go somewhat against the spirit of wxWindows? If it's such a trivial excercise (as I've now discovered) to embed one widget in a proper window why doesn't the wxGTK use such techniques to mimic the wxMSW one. (Arbitrary choice of wxGTK/wxMSW there, I have no preference for MSW :wink:
Or has this subject been debated to death elsewhere?

The first goal of the platform ports is to use native widgets wherever possible, but when the native widget is just too different then a generic implementation is used. For example on wxGTK and others the wxListCtrl and wxTreeCtrl are generic implementations that are written using only wxWindows itself. But for things like the wxStaticBitmap where the vast majority of the typical use cases can be done with the native widget then that is the preference.

···

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