简体   繁体   中英

Using wxPython's FloatCanvas widget, is there a way to get the ControlDown information of the event?

I am wondering if I can get the keyboard modifiers' status on EVT_FC_LEFT_UP events fired from a FloatCanvas.

I would prefer to do it without writing callbacks myself for keyUp and keyDown. I can't see a better method of grabbing the control status, than having a class member keep track of the modifier states over the whole window.

Is it possible to grab the state of the control key inside of the EVT_FC_LEFT_UP callback?

there is no isKeyDown type method in wxPython (afaik)

the only way I can see you getting this is

control_pressed = False
.....
self.float_canvas.bind(wx.EVT_KEY_DOWN,OnKeyDown)
self.float_canvas.bind(wx.EVT_KEY_DOWN,OnKeyUp)
.....
def OnKeyDown(evt):
    global control_pressed
    if evt.GetKeyCode() == 117 #(or whatever the code for ctrl is)
       control_pressed = True

def OnKeyUp(evt):
    global control_pressed
    if evt.GetKeyCode() == 117 #(or whatever the code for ctrl is)
       control_pressed = False

And then check control_pressed in your wx.EVT_LEFT_UP event handler

also in real life(tm) I suspect you would want this all in a class not globals

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM