Re: Re: GenButton and acceleratorTable
Nicolas Pinault <[email protected]> Thu, 20 Dec 2018 18:06:32 +0100
| Newsgroups | gmane.comp.python.wxpython.devel |
|---|---|
| Message-ID | <[email protected]> |
Le 19/12/2018 à 01:06, Robin Dunn a écrit : > TBH, it surprises me a little that it works with wx.Button. What > platform are you working on? Where is the keyboard focus at the time > the keys are pressed? The platform is Windows 10. My app has a Frame with a panel inside it. This panel contains a StaticBitmap. There is also a toolbar with buttons inside it. The focus is "somewhere". I tried to click on various elements then hit the accelerator keys without success. > > Do you have EVT_MENU or EVT_TOOL event bindings for those button IDs > or is the accelerator activating the button and sending an EVT_BUTTON? Neither EVT_MENU nor EVT_TOOLin my app. There are EVT_BUTTON event bindings for buttons. Accelerator table bind like this to buttons (wx.ACCEL_NORMAL, wx.WXK_RIGHT, self.button_n.GetId()) > > The accelerator table is designed to be a different way to trigger > menu events, so if you don't already have EVT_MENU bindings that would > be the thing to try. Just have them call the same handler already > bound to the EVT_BUTTON events. There is no menu in my app. Are you saying I have to use a menu in my app ? What I want to achieve is to trig actions either by clicking a button, or by hitting a key. I thought accelerator table is able to achieve this. Nicolas > > -- > Robin > > > > On Sunday, December 16, 2018 at 9:53:43 AM UTC-8, Nicolas Pinault wrote: > > Hi, > > Using WxPython 4.x : > > With the following code, accelerators work correctly : > > self.button_p = wx.Button(self.toolbar, wx.ID_ANY, > size=(32, 32)) > self.button_n = wx.Button(self.toolbar, wx.ID_ANY, > size=(32, 32)) > > > accelerator_table = wx.AcceleratorTable([(wx.ACCEL_NORMAL, > wx.WXK_LEFT, self.button_p.GetId()), > (wx.ACCEL_NORMAL, wx.WXK_RIGHT, self.button_n.GetId())]) > self.SetAcceleratorTable(accelerator_table) > > When replacing wx.Button() with wx.lib.buttons.GenButton(), > accelerators > do not work anymore. > I need owner drawn buttons, hence the use of GenButton(). > > How can I fix this issue ? > > Best regards, > Nicolas > > -- > You received this message because you are subscribed to the Google > Groups "wxPython-dev" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected] > <mailto:[email protected]>. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "wxPython-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.