Scroll wheel event from wxFrame to its parent (wxScrolledWindow)

63 views
Skip to first unread message

ardi

unread,
May 23, 2012, 6:26:28 AM5/23/12
to wx-users
Although I know it's not a recommended scenario, I finally had to make
a wxPanel child of a wxScrolledWindow. However, I'm having problems to
get scroll events working on the wxScrolledWindow. It seems they only
work if the cursor is outside of the child panel (i.e.: if the cursor
is outside of the wxPanel, the wxScrolledWindow gets the scroll wheel
events; if the cursor is on the wxPanel, such events don't arrive to
the wxScrolledWindow).

I'm not sure if I should do anything special for making the scroll
wheel events working on the parent wxScrollWindow. Should I do
anything, or should it work out of the box?

TIA

ardi

ardi

unread,
May 23, 2012, 6:27:42 AM5/23/12
to wx-users

Sorry, typo on the subject... it should be wxPanel instead of wxFrame

ardi

ardi

unread,
May 24, 2012, 3:02:51 AM5/24/12
to wx-users


On May 23, 12:26 pm, ardi <ardillasdelmo...@gmail.com> wrote:
[...]
>
> I'm not sure if I should do anything special for making the scroll
> wheel events working on the parent wxScrollWindow. Should I do
> anything, or should it work out of the box?

I think I can rewrite my question more clearly. I believe the issue is
that events don't propagate to parents on OSX (and I've read this is
also the case for GTK). So the question would be: What have to add to
my wxPanel class so that scroll wheel events are propagated to its
parent on OSX?

I tried to add a wxMouseEvent event handler to my wxPanel, and from
there I called ResumePropagation() with the constant defined for the
maximum level of propagation. However, the ScrolledWindow (which is
the wxPanel parent) doesn't receive such event.

Do I have to do another thing instead of (or in addition to)
ResumePropagation?

Btw, if the way to go is through ResumePropagation(), must the
ScrolledWindow call StopPropagation() to prevent the event propagating
further?

TIA

ardi

Vadim Zeitlin

unread,
May 24, 2012, 5:50:06 AM5/24/12
to wx-u...@googlegroups.com
On Thu, 24 May 2012 00:02:51 -0700 (PDT) ardi wrote:

a> I think I can rewrite my question more clearly. I believe the issue is
a> that events don't propagate to parents on OSX (and I've read this is
a> also the case for GTK).

wxMouseEvents never propagate, they shouldn't do this under MSW neither.

a> So the question would be: What have to add to my wxPanel class so that
a> scroll wheel events are propagated to its parent on OSX?

The simplest would probably be to call panel->Bind(ScrolledWindow::OnXXX)
i.e. just bind your event handler to the panel event instead of bothering
with propagation.

a> I tried to add a wxMouseEvent event handler to my wxPanel, and from
a> there I called ResumePropagation() with the constant defined for the
a> maximum level of propagation. However, the ScrolledWindow (which is
a> the wxPanel parent) doesn't receive such event.

This should normally work but, again, just binding to the event directly
is much simpler.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

ardi

unread,
May 27, 2012, 11:27:32 AM5/27/12
to wx-users


On May 24, 11:50 am, Vadim Zeitlin <va...@wxwidgets.org> wrote:
> On Thu, 24 May 2012 00:02:51 -0700 (PDT) ardi wrote:
>[...]
>
> a> So the question would be: What have to add to my wxPanel class so that
> a> scroll wheel events are propagated to its parent on OSX?
>
>  The simplest would probably be to call panel->Bind(ScrolledWindow::OnXXX)
> i.e. just bind your event handler to the panel event instead of bothering
> with propagation.

Thanks a lot for your advice. I just thought I can add a virtual
method in my widgets' classes that just calls such same method from
the parent, except the ScrolledWindow, which will process that event.
I believe this will get the result I wish (assign the scroll wheel
event to the first scrolledwindow found in the hierarchy), but I still
have to test it.

TIA

ardi

Reply all
Reply to author
Forward
0 new messages