Re: keyboard input

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

 



On Sun, Feb 13, 2011 at 8:25 PM, Maximilian Schneider
<max@xxxxxxxxxxxxxxxxx> wrote:
> Hello!
>
> I'm working on a CAD like program using input elements similar to
> inkscape; clicking the rectangle button or pushing the 'r' key.
>
> Whats the best way to implement something like this in C? I've taken a
> look at the inkscape source, but it being in C++, I can't make much use
> of it.

add a key press/release event handler for the window.

    switch (ev->keyval) {
    case GDK_KEY_foo:
          do_something ();
          break;
    ....

be careful about deciding whether you want to drive actions on press or release.

for better overall app design, make all "do_something()" methods into
GtkActions, and then

    switch (ev->keyval) {
    case GDK_KEY_foo:
            action = get_action ("do_something");
            action->activate ();

(the implementation of "get_action" is left as an exercise for the reader)

this then allows you to set up GUI elements like buttons as proxies
for the action, and then your entire GUI is nice and consistent.
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list


[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux