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;