Re: [gtk-list] accelerators




Hmm, I have progress. New angles on the questions...

On Wed, 29 Apr 1998, robert havoc pennington wrote:
> 
> I want to bind the escape key to delete_event for Gnome dialogs; but the
> accelerator functions seem to take characters, not keysyms. Is there a
> character for escape? 
> 

So I've tried '\x1b' and 27, and then tried using the letter a ('a'), but
the accelerator doesn't do anything AFAICT. I push the key, nothing
happens.

I have:

 dialog->accelerators = gtk_accelerator_table_new();
  gtk_widget_install_accelerator(GTK_WIDGET(dialog),
				 dialog->accelerators,
				 "delete_event",
				 'a', 0);

I also tried adding:
gtk_widget_set_events(GTK_WIDGET(dialog), GDK_KEY_PRESS_MASK);

theorizing that the dialog wasn't getting the key press; no dice.

What else is supposed to happen here? 

I have the same problem in 'gw,' none of the accelerators work; gw uses
GnomeApp, so it ought to be automatic, right? But they do work in 'gtt',
for example, and I can't see a difference in what's being done.  It's even
the same key, control-Q; I even tried changing gw to use 'Q' instead of
'q' to match gtt. Clearly I'm missing something.

> Separate question: is there a way to find out which widget is the default? 
> Specifically, I want to bind return to the current default button in the
> button box.
> 

After perusing some source, I have the following plan: attach a callback
to key_press_event, test the key for return, if it is GDK_Return then see
if GTK_WINDOW(dialog)->default_widget is a button and emit "clicked" on
the button if so.

I think this will work, but I'd love suggestions on a better way. Can
GtkAccelerator do anything other than emit signals, like callbacks? 

Thanks,

Havoc Pennington
http://pobox.com/~hp





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]