On 1 February 2013 00:06, Christian Mallwitz <c.mallw...@gmail.com> wrote:
> Hi Guys,
>
> Attached is a sample file creating a window with a simple tree view.
> When open one can press letter keys and it will open the little search
> input box that comes with Gtk3. What would one have to do if one would
> want have SHIFT-letter keys open the search box and do the stepping
> through the tree view rows? In my window/application I would want to
> use regular keys for something else even if the tree view has the
> focus. How about replacing/chaining on-key-press handlers? Any
> examples?
>
> I understand that is more of a Gtk than PyGtk question so feel free to
> tell me to go annoy someone else with my questions :-)

The simplest way I can think of to do this is to add a custom
key-press-event handler to the TreeView. You can then pass on those
key combinations you want to trigger the search to the default
handler, and handle the rest as you desire.

something like:

def key_press(self, view, event):
    if event.state & Gdk.ModifierType.SHIFT_MASK: return False # Shift
down, so propogate to the default handler
    <do stuff>
    return True # don't propogate this event further

And connect it up with a
   view.connect('key-press-event', self.key_press)

when creating the view.

Hope that helps.

Note that, once the search entry is open, it's handling its own
key-press events. If you want it to ignore letters without shift there
as well, things get more complicated - I think the best way to achieve
that would be setting your own entry widget via
view.set_search_entry() .

-- 
Neil Muller
drnlmul...@gmail.com

I've got a gmail account. Why haven't I become cool?
_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to