[Gtk-sharp-list] Re: Gtk.Dialog

Sergio Duran Sergio Duran <sergioduran@gmail.com>
Mon, 22 Nov 2004 00:31:18 -0600

Ok, first of all sorry for replying to myself, but I usually find my
answers after asking.. i get a period of insight and solve it all

I tested and got the gtk# code to work, I have to call 
Both of them, after calling button.Show() (in my example, it would be
after dialog.ShowAll()), I had been looking for this answer for some
hours, I browsed through some code that added accelerators, but I
wanted to use the HasDefault/ActivatesDefault aproach... it works now.

I'm still new at this, but I hope this will help some other newbies
around later. :)

On Mon, 22 Nov 2004 00:13:14 -0600, Sergio Duran <sergioduran@gmail.com> wrote:
> OK, here's the thing...
> I create a simple dialog with glade, it only has a Gtk.Entry, which
> has ActivatesDefault=true, and the Ok button on the ActionArea has
> hasDefault=true
> I load and autoconnect the gxml object and I get a dialog, when I
> press enter on the Gtk.Entry, the OK button is activated.
> Now, I write it using Gtk#:
> Dialog dialog;
> dialog = new Dialog();
> dialog.Modal=true;
> dialog.Title="dialog";
> Entry entry = new Entry();
> entry.ActivatesDefault=true;
> dialog.VBox.Add(entry);
> Button button=new Button(Stock.Ok);
> button.HasDefault=true;
> dialog.AddActionWidget(button, ResponseType.Ok);
> dialog.ShowAll();
> dialog.Response += new ResponseHandler(handleResponse);
> dialog.Run();
> but the Ok button doesn't get activated when I press enter, is there
> something I'm doing wrong? should I create a entry.Activated += new
> EventHandler that calls button.Activate();?
> Do I have to add an accelerator on the enter key, linked to the button?
> Thanks, cheers.