From c996eca3ba756a9cacfcff5f9449d6a5130684a6 Mon Sep 17 00:00:00 2001 From: tchernobog Date: Thu, 23 Feb 2006 12:50:19 +0000 Subject: [PATCH] - Add yet-not-functional code for managing the "return" keypress in the input entrybox git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@398 3ecf2c5c-341e-0410-92b4-d18e462d057c --- src/graphical_terminal_io.cc | 16 +++++++++++++++- src/graphical_terminal_io.hh | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/graphical_terminal_io.cc b/src/graphical_terminal_io.cc index 43605d1..594641e 100644 --- a/src/graphical_terminal_io.cc +++ b/src/graphical_terminal_io.cc @@ -54,10 +54,11 @@ GraphicalTerminalIO::GraphicalTerminalIO(TextSimulation* sim) Gtk::Box* cmdbox = manage(new HBox()); mainbox->pack_end(*cmdbox, false, false); + _text_input.signal_key_press_event().connect(sigc::mem_fun(*this, &GraphicalTerminalIO::_on_input_commit)); cmdbox->pack_start(_text_input); _send = manage(new Button(_("Send Command"))); - _send->signal_clicked().connect(sigc::mem_fun(*this, &sgpem::GraphicalTerminalIO::onSend)); + _send->signal_clicked().connect(sigc::mem_fun(*this, &GraphicalTerminalIO::onSend)); cmdbox->pack_start(*_send, false, true); _text_input.grab_focus(); @@ -118,3 +119,16 @@ GraphicalTerminalIO::is_full_duplex() { return true; } + +bool +GraphicalTerminalIO::_on_input_commit(GdkEventKey* event) +{ + // We should use Gdk::GDK_Return here, but it doesn't work for + // some reason!! + if((event->keyval & 0xFF0D) == 0xFF0D ) + { + onSend(); + return true; + } + return true; +} diff --git a/src/graphical_terminal_io.hh b/src/graphical_terminal_io.hh index fdd2c81..d39ec92 100644 --- a/src/graphical_terminal_io.hh +++ b/src/graphical_terminal_io.hh @@ -58,6 +58,8 @@ namespace sgpem { void onSend(); private: + bool _on_input_commit(GdkEventKey* event); + TextSimulation* _sim; Gtk::TextView _text_output; mutable Gtk::Entry _text_input;