Re: [gtkmm] More on Struggling with signal_key_press_event with code
- From: Ian Michell <ian michell hanzi co uk>
- To: gtkmm-list gnome org
- Subject: Re: [gtkmm] More on Struggling with signal_key_press_event with code
- Date: Sat, 06 Mar 2004 12:06:38 +0000
I have the code I am using here
LoginForm::LoginForm()
{
// Set Alignent
l_align = Gtk::manage(new Gtk::Alignment(Gtk::ALIGN_CENTER,
Gtk::ALIGN_CENTER, 0.0, 0.0));
// Create Table Layout
l_table = Gtk::manage(new Table(2,2));
l_align->add(*l_table);
// Create Login Button
l_button = Gtk::manage(new Gtk::Button("Login"));
// Create Login Labels
Label *lusername = Gtk::manage(new Gtk::Label("Username:"));
Label *lpassword = Gtk::manage(new Gtk::Label("Password:"));
// Create Entry Fields
l_i_username = Gtk::manage(new Gtk::Entry);
l_i_password = Gtk::manage(new Gtk::Entry);
// Configure Entry Fields
l_i_username->set_max_length(20);
l_i_password->set_max_length(20);
l_i_password->set_visibility(false);
l_i_password->set_invisible_char('*');
// Add Item to table
l_table->attach(*lusername, 0, 1, 0, 1, Gtk::FILL |
Gtk::SHRINK, Gtk::FILL | Gtk::SHRINK, 5, 5);
l_table->attach(*l_i_username, 1, 2, 0, 1, Gtk::FILL |
Gtk::SHRINK, Gtk::FILL | Gtk::SHRINK, 5, 5);
l_table->attach(*lpassword, 0, 1, 1, 2, Gtk::FILL |
Gtk::SHRINK, Gtk::FILL | Gtk::SHRINK, 5, 5);
l_table->attach(*l_i_password, 1, 2, 1, 2, Gtk::FILL |
Gtk::SHRINK, Gtk::FILL | Gtk::SHRINK, 5, 5);
// Add Aligned Table to frame
add(*l_align);
// Connect Signals
l_i_username->signal_key_press_event().connect(
SigC::slot(*this, &LoginForm::login_action));
}
LoginForm::~LoginForm()
{
}
bool LoginForm::login_action(GdkEventKey* k)
{
// Remove Login Frame
if (k && k->keyval == GDK_Return)
std::cout << "Hello World\n";
return false;
}
Please tell me where I am going wrong
On Sat, 2004-03-06 at 11:30, Ian Michell wrote:
> Hi,
>
> I am trying to connect a Gtk::Entry to a key, but I can't find any
> documentation that is definitive enough for me to accomplish this, as I
> am still trying to get used to GTKMM.
>
> Is there anyone that can help me with this?
>
> Ian
>
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]