Problem: Fetching keypresses from a gtkcomboboxentry



I'm developing an app where the user is supposed to enter text commands,
which are executed upon pressing enter and kept in a history.

For this task I have selected a GtkComboBoxEntry (the entry art is the input
and the drop down menu keeps the history) but I have problems detecting
enter (or keypresses at all). In the reference manual it is stated that the
widget has no "activate" signal like the GtkButton widget, so instead I set
my program up to react on the "key-press-event", then check which key
is pressed and then take action.
However the callback function is only activated if a modifier key (shift/alt etc)
is pressed. If I instead use "key-release-event" everything is fine, but I would
want the program to react on presses (since every text editor is made that way
so it feels more natural).
My code (a basic dialect):

---stuff---

g_signal_connect(inputComboBoxEntry, "key-press-event", GTK_SIGNAL_FUNC(@userFormulaInput), 0)

---stuff---

' Function to filter the user input in the comboboxentry and react on CR presses.
function userFormulaInput cdecl (byval object as GtkObject ptr, byval event as gdkEventKey ptr, byval user_data as gpointer) as integer
  if event->keyval=&HFF0D then
    'Rock n' roll
    postExternalErrorMessage "The enter key was pressed!"
    return 1
  else
    postExternalErrorMessage "Some other key was pressed!" 
    return 0
  end if
end function


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