hello,
I'm trying to catch arrow keys to manipulate cursors in a plot. Now I tried both , wx.EVT_KEY_DOWN and wx.EVT_CHAR, and they seem to work equally bad ... ... if I press a normal character, the event is catched ... if I press an arrow key, I don't catch anything and even weirder ... ... after pressing an arrow key, I can't catch any normal characters anymore ? Who can enlighten me , thanks, Stef Mientki |
Stef Mientki wrote:
> <div class="moz-text-flowed" style="font-family: -moz-fixed">hello, > > I'm trying to catch arrow keys to manipulate cursors in a plot. > > Now I tried both , wx.EVT_KEY_DOWN and wx.EVT_CHAR, > and they seem to work equally bad ... > ... if I press a normal character, the event is catched > ... if I press an arrow key, I don't catch anything > and even weirder ... > ... after pressing an arrow key, I can't catch any normal characters > anymore ? > > Who can enlighten me , > thanks, > Stef Mientki > > </div> for me. For example, in my handler I just put the following to catch the left arrow key: <code> def onKey(self, event): keycode = event.GetKeyCode() if keycode == wx.WXK_LEFT: print 'You pressed left arrow!' event.Skip() </code> Mike |
> I bind to wx.EVT_KEY_DOWN on Windows XP and the arrow key's events > work for me. For example, in my handler I just put the following to > catch the left arrow key: hi Mike, I'm too on winXP, I bind to the graphical control, are you binding to the application ? cheers, Stef |
On Thursday 22 May 2008 15:02:40 Stef Mientki wrote:
> > I bind to wx.EVT_KEY_DOWN on Windows XP and the arrow key's events > > work for me. For example, in my handler I just put the following to > > catch the left arrow key: > > hi Mike, > I'm too on winXP, I bind to the graphical control, > are you binding to the application ? > > cheers, > Stef > and just created an accelerator table (with help from this group). That solved it. |
In reply to this post by Stef Mientki-2
Stef,
> <div class="moz-text-flowed" style="font-family: -moz-fixed"> >> I bind to wx.EVT_KEY_DOWN on Windows XP and the arrow key's events >> work for me. For example, in my handler I just put the following to >> catch the left arrow key: > hi Mike, > I'm too on winXP, I bind to the graphical control, > are you binding to the application ? > > cheers, > Stef > > > </div> I'm binding to a wx.Grid widget in my application. Still, I would think that would work. Maybe Robin or Andrea can give us some advice? Mike |
Mike Driscoll wrote:
> Stef, >>> I bind to wx.EVT_KEY_DOWN on Windows XP and the arrow key's events >>> work for me. For example, in my handler I just put the following to >>> catch the left arrow key: >> hi Mike, >> I'm too on winXP, I bind to the graphical control, >> are you binding to the application ? >> >> cheers, >> Stef >> > > I'm binding to a wx.Grid widget in my application. Still, I would think > that would work. Maybe Robin or Andrea can give us some advice? How are you doing the event binding? If you're not binding to the widget that has the focus then your handler will not be called. -- Robin Dunn Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython! |
hi Robin,
Robin Dunn wrote: > Mike Driscoll wrote: >> Stef, >>>> I bind to wx.EVT_KEY_DOWN on Windows XP and the arrow key's events >>>> work for me. For example, in my handler I just put the following to >>>> catch the left arrow key: >>> hi Mike, >>> I'm too on winXP, I bind to the graphical control, >>> are you binding to the application ? >>> >>> cheers, >>> Stef >>> >> >> I'm binding to a wx.Grid widget in my application. Still, I would >> think that would work. Maybe Robin or Andrea can give us some advice? > > How are you doing the event binding? > If you're not binding to the widget that has the focus then your > handler will not be called. > Good point, I forgot that, and it explains most behavior. I now setfocus explicitly to the plotcanvas, whenever I click on it, which greatly improves the behavior, because I can catch key events again, after using the arrow-keys. Indeed focus seems to be the major problem. So now when the plotcanvas has focus, it catches most keys, even windows-key, menu-key, special mm-keys, and after regaining focus it catches the keys again except : tab and arrow-keys. Tab and arrow keys moves the focus to another plotcanvas (also derived from wx.Window) in the same active window. The window is layout as follows: self.Splitter_Plots ,SplitterVer self.Panel ,PanelVer, 010 self.Panel_Top ,PanelHor, 11 Label_Top ,wx.StaticText self.Scope_Normal ,PlotCanvas ,self, Real_Time self.Panel_Bottom ,PanelHor Label_Bottom ,wx.StaticText self.Scope_History ,PlotCanvas_History ,self, Real_Time which for this specific problem can be simplified to self.Splitter_Plots ,SplitterVer self.Scope_Normal ,PlotCanvas ,self, Real_Time self.Scope_History ,PlotCanvas_History ,self, Real_Time now it seems to me that if the window is active, focus is set to one of the 2 plot-canvases. The tab key and the arrow keys, simply toggles focus between the 2 plot-canvases. As I want to use the arrow keys for finetuning a crosshair, (simply because it's the most human interpretation), how can I catch the arrow keys, and do something useful with it, other than toggling the focus. thanks, Stef |
Stef Mientki wrote:
> As I want to use the arrow keys for finetuning a crosshair, > (simply because it's the most human interpretation), > how can I catch the arrow keys, > and do something useful with it, > other than toggling the focus. Try adding the style wx.WANTS_CHARS. -- Robin Dunn Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython! |
Robin Dunn wrote: > Stef Mientki wrote: > >> As I want to use the arrow keys for finetuning a crosshair, >> (simply because it's the most human interpretation), >> how can I catch the arrow keys, >> and do something useful with it, >> other than toggling the focus. > > Try adding the style wx.WANTS_CHARS. > that works great !! Isn't the name a little bit strange: without "wx.WANT_CHARS" you can catch every (character) key except arrow-keys and tab, and with "wx.WANT_CHARS" you can catch also arrow-keys and tab ? cheers, Stef |
Stef Mientki wrote:
> > > Robin Dunn wrote: >> Stef Mientki wrote: >> >>> As I want to use the arrow keys for finetuning a crosshair, >>> (simply because it's the most human interpretation), >>> how can I catch the arrow keys, >>> and do something useful with it, >>> other than toggling the focus. >> >> Try adding the style wx.WANTS_CHARS. >> > thanks Robin, > that works great !! > > Isn't the name a little bit strange: > without "wx.WANT_CHARS" you can catch every (character) key except > arrow-keys and tab, > and with "wx.WANT_CHARS" you can catch also arrow-keys and tab ? Yeah, I think the name is basically a historical artifact that evolved from slightly different functionality, and also the name of the flag that is used for the Windows API. -- Robin Dunn Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython! |
Free forum by Nabble | Edit this page |