问题
I am using Ada together with the Gtk library. I would like to read the user's keyboard input and react individually on it, depending which keys he/she pressed. How can I access the keyboard input from the user?
回答1:
I'm not sure what you're looking for: 1) keystrokes or 2) editable text.
The game LinXtris handles main window key_press_event signals in the procedure On_Main_Window_Key_Pressed, which passes each
Gdk.Event.Gdk_Event_Key
on to theGame_Engine
.The Interaction demo cited here has a
Gtk.Editable
that handlesSignal_Insert_Text
in the procedureOn_Insert_Text
. The advantage is that the handler is called for single keystrokes, as well as pasted text.
来源:https://stackoverflow.com/questions/13534497/reading-keyboard-input-using-adagtk