Re: intercepting accelerator keypresses
- From: Jason Hildebrand <jason peaceworks ca>
- To: Alexander Larsson <alexl redhat com>
- Cc: gnome-components-list gnome org, gtk-devel-list gnome org
- Subject: Re: intercepting accelerator keypresses
- Date: 31 Mar 2003 18:39:40 -0600
On Mon, 2003-03-31 at 01:57, Alexander Larsson wrote:
> On 28 Mar 2003, Michael Meeks wrote:
>
> > Hi Jason,
> >
> > On Thu, 2003-03-20 at 19:45, Jason Hildebrand wrote:
> > > I'm implementing the NautilusView interface for vim, so that vim can be
> > > used to view/edit a file in Nautilus, and have run into a snag wrt
> > > keypresses.
> > >
> > > Nautilus uses "Escape" as an accelerator for the "View->Stop" menu item.
> > > This prevents the use of Esc within the embedded Vim to jump back to
> > > command-mode, since Nautilus seems to swallow this keypress (even when
> > > the menu item is insensitive). There are other accelerators which
> > > conflict with vim keypresses as well.
> > >
> > > Is there a way for the control to get first dibs on handling these
> > > keypresses?
> >
> > AFAIK no - the event comes from X itself, to the toplevel window and
> > thus it gets first go at it. Of course - if you have the focus in the
> > child window then the same thing applies in reverse - you get the first
> > go at it. I'm afraid I don't fully understand the focus handling issues
> > with Controls / Window Managers / Sloppy focus etc. ;-) but Federico
> > does, so I'd bother him about it if you can find a spare moment from
> > him.
>
> The escape accelerator for view->stop has been removed in CVS head. It
> conflicted with several other uses of escape in Nautilus and was only
> introduced (semi-)recently.
Hi Alexander,
Thanks for the tip. Unfortunately, though, this doesn't solve the
problem in general. There are several other Nautilus accels which I
need to intercept.
For anyone who's interested, I came up with a (somewhat broken)
solution, after much digging through gtk/bonobo source code.
It seems like if you create an accelerator group in the control and
attach it to the GtkPlug, like this:
group = gtk_accel_group_new();
plug = (BonoboPlug *)bonobo_control_get_plug(control);
gtk_window_add_accel_group(GTK_WINDOW(plug), group);
closure = g_cclosure_new (G_CALLBACK (key_press_event), NULL,
(GClosureNotify)g_free);
gtk_accel_group_connect(group, GDK_Escape, 0, 0, closure);
closure = g_cclosure_new (G_CALLBACK (key_press_event), NULL,
(GClosureNotify)g_free);
Then those specific keys will be intercepted and passed to the control.
Unfortunately the code which supports this (located in
GtkSocket/GtkPlug) is broken in current gtk versions. I provided a
small patch to fix it and filed a bug
(http://bugzilla.gnome.org/show_bug.cgi?id=108927) , so hopefully it'll
work again soon. :)
peace,
Jason
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]