intercepting cursor keys

What I want to do is intercept up/down cursor in certain textctrls so
that when the control has focus the value can be incr/decremented
using the cursor keys.

Other controls such as listboxes should function normally with the
cursor keys.

The only way I could think of to do this was create 2 hidden buttons,
set up accelerators for the up/down keys to generate the button
command events, in the event handlers test for the correct controls
having focus, and if so, incr/decrement the value and otherwise call
evt.Skip()

The problem is that the listbox on the screen doesn't respond to up/
down any more.

Setting the event object doesn't seem to do anything. This is what I
have:

    def OnUpCursor(self,evt):
        focus = self._focus_test()
        if focus is None:
            evt.SetEventObject(focus)
            evt.Skip()
            return
        val = int(focus.Value)
        focus.Value = str( val+1 )

Does anyone have any ideas that could help me here?

Thanks.
Rick King
Southfield MI

After posting this I realized what I am talking about is handled quite well with a spin control.

Rick King

···

On Tue, Jun 8, 2010 at 9:56 AM, rick rickbking@gmail.com wrote:

What I want to do is intercept up/down cursor in certain textctrls so

that when the control has focus the value can be incr/decremented

using the cursor keys.

Other controls such as listboxes should function normally with the

cursor keys.

The only way I could think of to do this was create 2 hidden buttons,

set up accelerators for the up/down keys to generate the button

command events, in the event handlers test for the correct controls

having focus, and if so, incr/decrement the value and otherwise call

evt.Skip()

The problem is that the listbox on the screen doesn’t respond to up/

down any more.

Setting the event object doesn’t seem to do anything. This is what I

have:

def OnUpCursor(self,evt):

    focus = self._focus_test()

    if focus is None:

        evt.SetEventObject(focus)

        evt.Skip()

        return

    val = int(focus.Value)

    focus.Value = str( val+1 )

Does anyone have any ideas that could help me here?

Thanks.

Rick King

Southfield MI

Hi,

···

On Tue, Jun 8, 2010 at 10:13 AM, Rick King <rickbking@gmail.com> wrote:

After posting this I realized what I am talking about is handled quite well
with a spin control.

Yes

However if you want to do it with the TextCtrl you can Bind to
EVT_KEY_DOWN (or UP) and check the events KeyCode to see if its is
equal to wx.WXK_UP or wx.WXK_DOWN and respond accordingly.

Cody