How to bind to ctrl-leftclick

Dan Bar Dov wrote:

I want to distinguish between a button beling left-clicked
and the same button being control-left-clicked.

I cannot figure out an event or a method to do the latter.

Bind to the mouse down, and then check to see if the control key is down:

import wx

class MyButton(wx.Button):
  def __init__(self, *args, **kwargs):
    super(MyButton, self).__init__(*args, **kwargs)
    self.Bind(wx.EVT_LEFT_DOWN, self.onLeftDown)

  def onLeftDown(self, evt):
    if evt.ControlDown():
      print "Control left down"
    else:
      print "left down"

if __name__ == "__main__":
  app = wx.App()
  frm = wx.Frame(None, -1, "Testing")
  but = MyButton(frm, label="Click me")
  frm.Show()
  app.MainLoop()

···

--
pkm ~ http://paulmcnett.com