Handling keyboard accelerators like Control-Q and Control-F1.


In my application, that has lots of buttons (it's a calculator), I've
been assigning keyboard equivalents to these buttons with 
gtk_widget_add_accelerator(). As Havoc has pointed out I could use
gtk_button_new_with_mnemonic() for some of them, but others (like
the number buttons) aren't using Alt-<whatever>, so I wrote a simple
generic routine.

But how do you handle keyboard accelerators like Control-Q and Control-F1
where they is no matching button to assign the keyboard accelerator to a
button "clicked" action?

One way I can see to do this is in my main frame event handler. The
problem there is that the events are separate. First a key down event for 
the Control key, then one for the other key down. I could use a variable 
to save the current state of the Control key, but I feel there has to be 
a better way.

If you have any pointers on how to solve this I'd appreciate it.

Pointers to existing code in GNOME Bonsai would be fine.


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