crategus / cl-cffi-gtk

cl-cffi-gtk is a Lisp binding to the GTK+ 3 library.
http://www.crategus.com/books/cl-cffi-gtk
146 stars 33 forks source link

generic keybinding example #17

Closed zabbal closed 10 years ago

zabbal commented 10 years ago

It would be handy to have generic key binding example: for example I'd like my gtk app to fire particular function when "ctrl+t" or "ctrl+n" is pressed. I know about accelerators but it seems they are tied to menus and it's unclear which gtk signal I have to watch for if I don't have any menus in my gtk app but still wold like to handle some key bindings explicitly.

crategus commented 10 years ago

Thank you very much for your interest in the cl-cffi-gtk library.

I have no example by the hand. The reason is, that I am not really a expert of all aspects of GTK+. I think it is the best to consult some references and examples for the C library and to translate the C examples to Lisp using the cl-cffi-gtk library.

The only example I have up to now is the demo "Application window" which connects accelerators as you have observed to menu items. You will find the GTK+ demo in the directory ../demo/gtk-demo. Load the file "gtk-demo.lisp" from the Lisp prompt. Change to the package "gtk-demo" and start the demo with (main).

Dieter Kaiser

zabbal commented 10 years ago

Well, my problem is with how ctrl-mask is handled and represented in clisp bindings? In c-code I've got to catch key_pressed event and check for GDK_CONTROL_MASK - how do I do this in cl-cffi-gtk? For instance - how do I translate code from http://stackoverflow.com/questions/10134956/in-simple-gtk-key-press-event-example-gdk-shift-mask-seems-to-be-ignored to clisp?

crategus commented 10 years ago

Sorry, about my late answer. I was absent some from the project. After two years of work, I needed some holiday from the project.

The flag GDK_CONTROL_MASK is of type GKD_MODIFER_TYPE which is implemented in the Lisp binding as the type gdk-modifier-type. This is the documentation http://www.crategus.com/books/cl-cffi-gtk/pages/gdk_sym_gdk-modifier-type.html

For example the flag GDK_CONTROL_MASK will be in Lisp the keyword :control-mask.

I hope this information solves your problem.

Dieter Kaiser