How to check if CTRL is pressed during wx.EVT_SCROLLWIN_LINEDOWN event?

Hi,

I have a ScrolledWindow. When I click on scroll down button on the scroll bar, I want to check if CTRL key is pressed. I do:

self.Bind(wx.EVT_SCROLLWIN_LINEDOWN, self.onScrollClickDown)

def onScrollClickDown(self, event):
ctrl_is_pressed = event.ControlDown()


But it says EVT_SCROLLWIN_LINEDOWN event doesn’t have a ControlDown() attribute.

So how do I check if CTRL is pressed during a EVT_SCROLLWIN_LINEDOWN event?

I can tell you something that is likely to work, but you have to sit
through a brief lecture first.
The problem you have here is one of timing. The
EVT_SCROLLWIN_LINEDOWN event is heavily processed. It started out
with a mouse click, but that mouse click was trapped by an event
handler in the scrollbar code. It took a look at exactly where
inside its window the click occurred, and then generated its own
event. EVT_SCROLLWIN_LINEDOWN is not trying to tell you that the
mouse was clicked in the scrollbar. It’s telling you that a “line
down” scroll event occurred. That event can also be generated by
using the cursor keys, which is why it doesn’t have the normal
click/keystroke methods. It’s a different kind of event.
The bigger problem is user expectations. Scroll bars need to be
simple, reliable and predictable. They work the way they do because
those are the UI standards that have been applied for decades. When
you try to make a tweak like this, you are breaking those
expectations. You need to think very seriously before you alter the
way a scrollbar responds.

···

steve wrote:

      I have a ScrolledWindow. When I click on scroll down button

on the scroll bar, I want to check if CTRL key is pressed. I
do:

self.Bind(wx.EVT_SCROLLWIN_LINEDOWN, self.onScrollClickDown)

def onScrollClickDown(self, event):
ctrl_is_pressed = event.ControlDown()

      But it says EVT_SCROLLWIN_LINEDOWN event doesn't have a ControlDown() attribute.



      So how do I check if CTRL is pressed during a

EVT_SCROLLWIN_LINEDOWN event?

` def onScrollClickDown(self, event):``

``        if wx.GetKeyState(wx.WXK_CONTROL):``

``            print "Control key is down"`
-- Tim Roberts, Providenza & Boekelheide, Inc.

timr@probo.com