I'm trying to build a remote control emulator app as a learn wx project. I have
lots of buttons to emulate remote keys as you would expect, and i've bound them
to an event handler using the wx.EVT_BUTTON event (and use defined button id's
to determine which key was pressed).
Problem is, remote controls allow you to hold down a button which would in wx
context terms repeat the event handler call but my handler is only called once.
What's the best way to go about detecting the mouse button is held down on a
button, i've looked at various options but nothing seems obvious, i expect it's
probably not!?
Thanks
Nick
Hi Nick,
Don’t do your “action” in the event handler. Do it in another handler.
Bind the wx.EVT_LEFT_DOWN event and start a wx.Timer with the frequency you want for the repetition. Don’t forget to evt.Skip() the LEFT_DOWN event.
Bind the wx.EVT_LEFT_UP event and in the handler stop the timer. Again, don’t forget to skip the event.
Bind the timer event and do your “action” there.
Peter
···
On Sat, Mar 7, 2009 at 3:35 AM, Nick Byrne nick@incension.com wrote:
I’m trying to build a remote control emulator app as a learn wx project. I have
lots of buttons to emulate remote keys as you would expect, and i’ve bound them
to an event handler using the wx.EVT_BUTTON event (and use defined button id’s
to determine which key was pressed).
Problem is, remote controls allow you to hold down a button which would in wx
context terms repeat the event handler call but my handler is only called once.
What’s the best way to go about detecting the mouse button is held down on a
button, i’ve looked at various options but nothing seems obvious, i expect it’s
probably not!?
Thanks
Nick
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
–
There is NO FATE, we are the creators.
blog: http://damoc.ro/
Peter Damoc <pdamoc <at> gmail.com> writes:
Hi Nick,Don't do your "action" in the event handler. Do it in another handler.
Bind the wx.EVT_LEFT_DOWN event and start a wx.Timer with the frequency you want
for the repetition. Don't forget to evt.Skip() the LEFT_DOWN event.
Bind the wx.EVT_LEFT_UP event and in the handler stop the timer. Again, don't
forget to skip the event.Bind the timer event and do your "action" there.Peter
On Sat, Mar 7, 2009 at 3:35 AM, Nick Byrne <nick <at> incension.com> wrote:I'm
trying to build a remote control emulator app as a learn wx project. I have
lots of buttons to emulate remote keys as you would expect, and i've bound them
to an event handler using the wx.EVT_BUTTON event (and use defined button id's
to determine which key was pressed).
Problem is, remote controls allow you to hold down a button which would in wx
context terms repeat the event handler call but my handler is only called once.
What's the best way to go about detecting the mouse button is held down on a
button, i've looked at various options but nothing seems obvious, i expect it's
probably not!?
Thanks
Nick
_______________________________________________
wxpython-users mailing listwxpython-users <at>
lists.wxwidgets.orghttp://lists.wxwidgets.org/mailman/listinfo/wxpython-users
-- There is NO FATE, we are the creators.blog: http://damoc.ro/
_______________________________________________
wxpython-users mailing list
wxpython-users <at> lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Thank you very much for a clear explanation Peter, that worked perfectly and
saved me a few grey hairs!
Nick