Cursor movement question
Jive Dadson
notontheweb at noisp.com
Sat May 23 18:49:51 EDT 2009
Aahz wrote:
> In article <wxoRl.328387$Yx2.227908 at en-nntp-06.dc1.easynews.com>,
> Jive Dadson <notontheweb at noisp.com> wrote:
>> Gosh, you guys are slow. :-) I figured it out.
>
> Perhaps you could post the solution for posterity's sake?
The double secret magic encantation is "WarpPointer." Unfortunately, it
does not work in a plain vanilla ScrolledWindow. ScrolledWindow captures
the event and scrolls by the default scroll amount of 20 pixels. I think
I can figure out a work-around, but I have not yet done so.
self.bmp.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
def OnKeyDown(self, event):
# Use direction keys to move cursor one pixel
x,y = event.GetPosition()
keycode = event.GetKeyCode()
X = 0
Y = 0
if keycode == wx.WXK_LEFT:
X = -1
elif keycode == wx.WXK_RIGHT:
X = 1
elif keycode == wx.WXK_UP:
Y = -1
elif keycode == wx.WXK_DOWN:
Y = 1
else:
return
x = max(0,min(self.size[0]-1,x+X))
y = max(0,min(self.size[1]-1,y+Y))
self.bmp.WarpPointer(x, y)
self.bmp.SetFocus()
More information about the Python-list
mailing list