Hi
zedenator wrote:> Im writing a simple gui app where I need to receive mouse click events
> from the shapes drawn on a canvas (a simple object inheriting from
> ScrolledWindow, as seen in many examples). Shapes arent buttons so I
> think I''ll need to be checking the coordinates to be able to work
out
> what''s been clicked exactly, but please correct me if Im wrong.
>
> So I went and wrote a little prototype and it seems to me that the
> only widget capable of receiving mouse events is a Panel. I''ve
tested
> this by placing a catch-all evt_mouse_events right in my App class
> ("event tables are searched up through the hierarchy of windows",
say
> the WxWidgets docs), but its only trigered when I move the cursor over
> the Panel and not ScrolledWindow or, in fact, anywhere else in the app
> window.
>
> This isnt quite what I was expecting, so I guess I have two questions:
>
> 1 - am I thinking correctly about the Panel being the only widget
> capable of receiving mouse events?
> 2 - any other way I can detect user clicks?
>
Well firstly glad it worked out. So far as I understand, in WxWidgets /
WxRuby there are two broad types of events
1) ''Command'' events that result from interactions specific to
a widget -
eg pressing a button, selecting an item in a list or dropdown, etc
2) Other events that are generic GUI interactions - such as mouse
movement, resizing, scrolling, maximising or closing windows
The first sort are bubbled up, so that panels or frames can capture
command events generated by widgets they contain. The second sort
aren''t, so you need to define an event handler within the relevant
widget itself - for example, the panel.
In your example, I guess Panels are useful because they cover a large
space and receive the events generated within them - but I could be
wrong on this.
alex