I have an entry object guess
, when I'm done typing inside of it, I need to have it perform the same behavior after hitting ENTER
as the OK
button.
I also need the focus of the keyboard to be on this entry object as soon as it's window pops up. I used guess->grab_focus();
but all it did was pre-select the text already inside the entry object. It was not editable unless I clicked on the entry object and selected all text again.
When OK
is clicked, it calls on_ok()
.
Here is my code so far:
Gtk::Entry *guess = Gtk::manage(new Gtk::Entry());
guess->set_text("Enter your guess here");
//guess->grab_focus();
guess->set_size_request(300,10);
vBox3->add(*guess);
okButton->signal_clicked().connect(sigc::bind<Gtk::Entry*>(sigc::mem_fun(*this, &MainWindow::on_ok), guess));
Prototype of the on_ok()
function:
void on_ok(Gtk::Entry*);
Aucun commentaire:
Enregistrer un commentaire