[Gtk-sharp-list] Gtk.Entry.TextInserted

Francis Brosnan Blázquez francis@aspl.es
Fri, 26 Nov 2004 20:35:33 +0100


El vie, 26-11-2004 a las 13:18 -0600, Sergio Duran escribió:
> I've been trying to use a TextInserted event handler for a Gtk.Entry,
> but when the execution reaches the end of the method, my program
> exits.
Hi Sergio,

Your program doesn't exit because using some handler or not. Your
program exists, mainly, due to an Application.Quit () or something
similar. Try to checkout this.
> 
> How can I use that handler? or is this the handler I'm suposed to use
> if I want to add input validation on an Entry, to prevent invalid
> chars from beeing typed?
> 
> this is my sample code:
> 
> class specialEntry : Entry {
>   public specialEntry() {
>      TextInserted +=  new TextInsertedHandler(textInserted);
>   }
>   private void textInserted(object o, TextInsertedArgs args) {
>      Console.WriteLine("Entry changed");
>   }
> }
> 
> I pack it as usual, and after "Entry changed" the program exits.

You can use Changed signal to catch whenever the entry content has
changed. Then, you can keep the previous state to changed signal emition
and check if the actual entry content is right. If so, keep the new
actual state. But, if entry content is wrong, simply replace it with the
previous state.


Cheers.

> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>