Re: Accelerators and gtk_grab_add
- From: Tim Janik <timj gtk org>
- To: Matt Carlson <mindbender lokigames com>
- Cc: Havoc Pennington <hp redhat com>, Gtk+ MList <gtk-list gnome org>
- Subject: Re: Accelerators and gtk_grab_add
- Date: Thu, 27 Jul 2000 00:39:49 +0200 (CEST)
On Wed, 26 Jul 2000, Matt Carlson wrote:
> Tim Janik wrote:
> >
> > On 24 Jul 2000, Havoc Pennington wrote:
> >
> > >
> > > Matt Carlson <mindbender@lokigames.com> writes:
> > > > Hi folks. I'm having trouble with menu accelerators whenever I
> > > > bring up a modal dialog. I tried to disable them through the use of
> > > > gtk_grab_add(), but accelerators don't seem to be affected by this
> > > > function. Is there a way to do this? Thanks in advance for your
> > > > time.
> > > >
> > >
> > > Yikes, that seems like a pretty serious bug. CC'd Tim to see if he has
> > > comments.
> >
> > i'm not able to reproduce this, and i couldn't imagine how
> > accelerators could get delivered to windows while there's
> > a modal dialog popped up (dialog modality does involve gtk_grab_add()
> > btw).
>
> Yah, I know. If fact, I don't even bother with the gtk_window_set_modal()
> function.
>
> > so if you could send me a short test case matt, that'd be aprechiated.
>
> I've attached it. I've programmatically set the menuitem accelerator to the
> 'N' key...for convenience. Just run the program, select the "Do Something"
> menu option, move the window out of the way, move the cursor over the main
> window, use the 'N' key to bring up another dialog (which shouldn't happen).
> Thanks for your help. :)
ok, that's something to work from. the problem is the accelerator
you setup programmatically:
/* Just for kicks let's add an accelerator programmatically */
gtk_widget_add_accelerator( menuitem, "activate",
gtk_accel_group_get_default(),
GDK_N, 0, GTK_ACCEL_VISIBLE );
you're using the global default accelerator group that _all_ windows will
resort to if they can't handle the keypress.
what you actually want is to create a new accelerator group per menubar,
install the accelerators on that and add it to the window with
gtk_window_add_accel_group().
i can see why you used this though, i'll put the foolowing on my 2.0 todo list:
1) provide gtk_menu_bar_get_accel_group() (creates the menubar accel group for you,
you just need to add it to the window then)
2) gtk_window_get_default_accel_group() (should be provided by havoc's recent patches
already), to be used for non-menu, per-window accelerators
3) rename gtk_accel_group_get_default() to gtk_accel_group_get_global(), since that's
how it's really used.
[i didn't actually run your programm when i saw your usage of
gtk_accel_group_get_default(), so if the above advice doesn't fix
things for you, bug me again ;)]
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]