I have a frame that contains a ListBox as well as other widgets. That
frame needs to be able to respond to scroll events; however, if you
interact with the ListBox, then the frame will stop receiving them
(because the ListBox is receiving them instead). Expected behavior,
but unwanted in my case.
Is there some way to either tell the ListBox not to receive scroll
events, or (ideally) to only receive them if the mouse is currently
over the ListBox?
Failing that, I can use SetFocus() in my mouse event handler (which
still receives mouse motion events), to move focus to some other
widget in the frame that doesn't receive scroll events. Thus as soon
as the mouse moves over some part of the frame that doesn't have the
ListBox, I get scroll events again. However, that effectively causes
that frame to use "focus follows mouse" behavior, i.e. the frame pops
to the front if it is moused over, unlike every other frame in my
program.
So is there some way to tell if the frame currently has focus as a
whole (i.e. any one of its children currently has focus)? I see
wx.Window.FindFocus() to get the current Window that has focus, but
that would seem to require me to climb the Window hierarchy to see if
any element in the Window's focus is the Frame I care about.
I have a frame that contains a ListBox as well as other widgets. That
frame needs to be able to respond to scroll events; however, if you
interact with the ListBox, then the frame will stop receiving them
(because the ListBox is receiving them instead). Expected behavior,
but unwanted in my case.
It sounds like you are talking about mouse scroll wheel events, correct?
Is there some way to either tell the ListBox not to receive scroll
events, or (ideally) to only receive them if the mouse is currently
over the ListBox?
Since wx.ListBox is a native widget we don't really have that level of control over it. Catching and ignoring the wheel events being delivered to it might work, but there is no way to be certain of that and it could change on new or updated platforms.
Failing that, I can use SetFocus() in my mouse event handler (which
still receives mouse motion events), to move focus to some other
widget in the frame that doesn't receive scroll events. Thus as soon
as the mouse moves over some part of the frame that doesn't have the
ListBox, I get scroll events again. However, that effectively causes
that frame to use "focus follows mouse" behavior, i.e. the frame pops
to the front if it is moused over, unlike every other frame in my
program.
So is there some way to tell if the frame currently has focus as a
whole (i.e. any one of its children currently has focus)? I see
wx.Window.FindFocus() to get the current Window that has focus, but
that would seem to require me to climb the Window hierarchy to see if
any element in the Window's focus is the Frame I care about.
Try frame.IsActive(), although doing it the hard way would only be a few lines of code.
So is there some way to tell if the frame currently has focus as a
whole (i.e. any one of its children currently has focus)? I see
wx.Window.FindFocus() to get the current Window that has focus, but
that would seem to require me to climb the Window hierarchy to see if
any element in the Window's focus is the Frame I care about.
Try frame.IsActive(), although doing it the hard way would only be a few
lines of code.
frame.IsActive() did the trick, thanks! And yes, I was referring to
mousewheel events. I could have been clearer about that.
--
Robin Dunn
-Chris
···
On Fri, Oct 26, 2012 at 11:22 AM, Robin Dunn <robin@alldunn.com> wrote: