Re: Send global keyboard events in dialog to child window
Robin Dunn <[email protected]> Tue, 18 Dec 2018 16:05:53 -0800 (PST)
| Newsgroups | gmane.comp.python.wxpython.devel |
|---|---|
| Message-ID | <[email protected]> |
You should be able to do that with the wx.UIActionSimulator, although it works better on some platforms than others so you may need to do some experimentation to find the right combination of things that works for your use case. -- Robin On Monday, November 26, 2018 at 4:07:19 PM UTC-8, Jasper Alexion wrote: > > Hello, > > *Use case* > We have a search dialog containing a wx.ListCtrl and some buttons. We > would like to be able to scroll though the list using the arrow/pgup/pgdn > keys from anywhere in the dialog, also when the wx.ListCtrl does not have > focus. > > *Problem* > I'm able to catch global keyboard events in the dialog using an > wx.AccelleratorTable. However, i'm not sure how to send this key event to > the wx.ListCtrl. I could call the list myself, for example using > wx.ListCtrl.GetNextItem(), but it doesn't seem possible use this for > pgup/pgdn. > > I've tried to create wx.KeyEvents using: > > pgdnEvent = wx.KeyEvent(wx.EVT_CHAR.typeId) > pgdnEvent.m_keyCode = wx.WXK_PAGEDOWN > self.listView.GetEventHandler().ProcessEvent(pgdnEvent) > > > This doesn't work. My guess is that this does not simulate an actual > keypress but just sends the event like it would be sent after a real > keypress. If i manually bind wx.EVT_CHAR in the wx.ListCtrl i do see these > events being processed. > > Another attempt was using wx.UIActionSimulator. I don't really understand > how i should be using this for my use case because there doesn't seem to be > a way to send a simulated action towards a certain widget. So simulating > another pgdn event would just be processed the by my accelerator table and > not the wx.ListCtrl. > > I'm using wxPython 3.0.2.0 win32 with Python 2.7. Solutions using newer > versions are fine too. > > I'm looking forward to your solutions. I hope i'm missing something > obvious here :) > > Many thanks, > Jasper > > ______digitale bijlage______ > > De informatie verzonden met dit E-mail bericht is uitsluitend bestemd voor > de geadresseerde. Gebruik van deze informatie door anderen dan de > geadresseerde is niet toegestaan, evenals openbaarmaking, vermenigvuldiging > en/of verstrekking aan derden. Alexion Software is niet aansprakelijk voor > de juiste en volledige overbrenging van de inhoud van verzonden e-mail > berichten, noch voor een tijdige ontvangst daarvan. De aan u verzonden > digitale informatie mag uitsluitend gebruikt worden voor het desbetreffende > project. De aan u verzonden digitale informatie wordt zonder enige > verantwoordelijkheid onzerzijds verstrekt. Aan de door u digitaal ontvangen > informatie kunnen geen rechten worden ontleend ten opzichte van Alexion > Software. Het is raadzaam om de ontvangen bestanden voor het gebruik te > controleren op eventuele aanwezigheid van virussen. Verlies van gegevens > door het niet maken van back-ups is niet voor verantwoordelijkheid van > Alexion Software. > > Op al onze offertes en facturen zijn van toepassing Algemene Voorwaarden > zoals gedeponeerd bij de KvK Midden-Nederland onder nummer 30174840 van > ICT~Office. Deze zullen wij u op uw eerste verzoek kosteloos toesturen. Een > kopie van deze algemene voorwaarden vindt u op > alexion.nl/algemene-voorwaarden > -- 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.