Re: No macro in gdkkeysyms.h seems to match the enter key.



2012-05-04 15:02, Carlos Franke skrev:
Hi!


Short version:

On my first try on handling keypress events with gtkmm, I am stuck with a probably trivial problem: The GdkEventKey.keyval of hitting the enter key does not seem to match any of the *Enter* or *Return* macros in gdkkeysyms.h. GdkEventKey.keyval is supposed to be compared to the values in gdkkeysyms.h, right? What is the right macro for the enter key?


More details:

If in a callback method I do thus:

bool My_widget::my_callback(GdkEventKey* event)
{
std::cout << event->keyval << std::endl;
std::cout << GDK_KEY_Return << std::endl;
std::cout << GDK_KEY_KP_Enter << std::endl;
std::cout << GDK_KEY_ISO_Enter << std::endl;
std::cout << GDK_KEY_3270_Enter << std::endl;
std::cout << GDK_KEY_RockerEnter << std::endl;

return false;
}

… it shows that event->keyval is not matched by any of the macros I tried. This is the output:
65515
65293
65421
65076
64798
269025061

Did I miss the right macro for the enter key? If so, what is it? Is there any documentation on the macros in gdkkeysyms.h, or do you have to guess which macro to use for which key by their names?


Carlos
Gtk+ uses GDK_KEY_Return, GDK_KEY_ISO_Enter and GDK_KEY_KP_Enter to test for the Enter key.

When I added a line to print out event->keyval in
http://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/combobox/entry_text/examplewindow.cc
function ExampleWindow::on_entry_key_press_event(GdkEventKey* event), the result is
0xff0d = 65273 = GDK_KEY_Return.

Your result is 65515 = 0xffeb = GDK_KEY_Super_L.
On my PC GDK_KEY_Super_L is the left Windows key (the one with the Microsoft Windows symbol, looking like a flexible window).

I run Linux Ubuntu 12.04 on quite an old PC. What operating system do you use? An unusual type of keyboard? Actually it's strange if gtk+/gtkmm programs work correctly, if your Enter key generates a key value that gtk+ does not recognize as an Enter key.

And no, I don't think there's any documentation of the macros in gdkkeysyms.h.

Kjell



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