fixed key bindings in notebook

Ok thanks, so it is not so trivial. I would like to use ctrl-page up in the stc to go
to the top of the document for example. It seems to me more logical, than the
ctrl-Pos1 or ctrl-home key.

···

On Tue, 18 Mar 2008 12:08:20 -0700, Robin Dunn <robin@alldunn.com> wrote:

Franz Steinhäusler wrote:

Hello, in my app, I want to assign for the stc control:
ctrl-page up ... for jump to document start
ctrl-page down ... for jump to document end

that keys seems to be fixed on changing the current notebook tabs.
How can I disable that keys, so I can use it in my app?
(I have my own hotkeys to change between the tabs of the notebook control with alt-cursor left and right).

The same applies for ctrl-tab and ctr-shift-tab. I want to use that combinations for my own and not letting
wxpyhton take control over those keys automatically.

It's real hard to intercept the navigation keys before they get stolen
for the navigation, mainly because they are caught before the focused
window even sees the event. You can try using EVT_KEY_DOWN or
EVT_CHAR_HOOK on the notebook, or maybe EVT_NAVIGATION_KEY, then you can
make a call from the handler back to the currently active page to do
whatever you would have done from a normal key event in that class.
Another option is to try using one of the non-native notebooks.

--
Franz Steinhaeusler

Franz Steinhäusler wrote:

···

On Tue, 18 Mar 2008 21:07:58 +0100, Franz Steinhäusler <franz.steinhaeusler@gmx.at> wrote:

So, I am not sure, if that is normal, but after trying and searching all code and others, that tinkered code even works for me! :slight_smile:

in wx.Notebook derived class:

self.Bind(wx.EVT_NAVIGATION_KEY, self.OnNavigationKey)

    def OnNavigationKey(self, event):
                ignorekey = False
        if wx.GetKeyState(wx.WXK_CONTROL):
            if wx.GetKeyState(wx.WXK_PAGEUP) or wx.GetKeyState(wx.WXK_PAGEDOWN):
                ignorekey = True
            if wx.GetKeyState(wx.WXK_TAB):
                ignorekey = True
        if ignorekey:
            keycode = 0
            if wx.GetKeyState(wx.WXK_TAB):
                keycode = wx.WXK_TAB
            if wx.GetKeyState(wx.WXK_PAGEUP):
                keycode = wx.WXK_PAGEUP
            if wx.GetKeyState(wx.WXK_PAGEDOWN):
                keycode = wx.WXK_PAGEDOWN
            evt = wx.KeyEvent()
            evt.m_controlDown = wx.GetKeyState(wx.WXK_CONTROL)
            evt.m_keyCode = keycode
            evt.m_shiftDown = wx.GetKeyState(wx.WXK_SHIFT)
            evt.SetEventType(wx.wxEVT_KEY_DOWN)

            self.grandparent.txtDocument.GetEventHandler().ProcessEvent(evt)
        else:
            event.Skip()

It seems to work!
  

That's great, it does work for me, too. I just got rid of the self.grandparent line. Have you got alt-left and alt-right to work, too? -ak