[Gtk-sharp-list] RichTextBox.TextChanged (event) equivalent in GTk.?

David Cantin dcantin at gmail.com
Thu Sep 25 13:15:19 EDT 2008


I can do something like :

protected virtual void OnTextBufferChanged(object o, System.EventArgs e)
{
   string temp = this.textview1.Buffer.Text; 
   string temp1 = Regex.Replace(temp, "[\x0011\x0012\u0060]","\'"); 
   string temp2 = Regex.Replace(temp1, "[\x0013\x0014]", "\""); 
   string temp3 = Regex.Replace(temp2, "[+\x0017\x0005\x0015]", ""); 
   string temp4 = Regex.Replace(temp3, "\x0016", "-");

   this.textview1.Buffer.Changed -= new
EventHandler(OnTextBufferChanged);

   this.textview1.Buffer.Text = temp4;

   this.textview1.Buffer.Changed += new
EventHandler(OnTextBufferChanged);

}



Le jeudi 25 septembre 2008 à 21:50 +0500, True Friend a écrit :
> 
> Ok I have added it to the MainWindow's constructor as follows.
> 
> this.textview1.Buffer.Changed += new
> EventHandler(OnTextBufferChanged);
> 
> The evnt handler is as follows.
> -----------------------------------------------
> protected virtual void OnTextBufferChanged(object o, System.EventArgs
> e)
>     {
>         string temp = this.textview1.Buffer.Text; 
>            string temp1 = Regex.Replace(temp, "[\x0011\x0012\u0060]",
> "\'"); 
>            string temp2 = Regex.Replace(temp1, "[\x0013\x0014]",
> "\""); 
>            string temp3 = Regex.Replace(temp2, "[+\x0017\x0005
> \x0015]", ""); 
>            string temp4 = Regex.Replace(temp3, "\x0016", "-");
>         this.textview1.Buffer.Text = temp4;
>     }
> -------------------------------------------
> And the result is an unlimited loop. Under is output at MD console
> output. 
> --------------------------------------------
> /usr/lib/libgobject-2.0.so.0(g_cclosure_marshal_VOID__VOID+0x4f)
> [0xb6964aff]
>     /usr/lib/libgobject-2.0.so.0(g_closure_invoke+0x1ff) [0xb695782f]
>     /usr/lib/libgobject-2.0.so.0 [0xb696c329]
>     /usr/lib/libgobject-2.0.so.0(g_signal_emit_valist+0x8ef)
> [0xb696dc1f]
>     /usr/lib/libgobject-2.0.so.0(g_signal_emit+0x29) [0xb696df69]
>     /usr/lib/libgtk-x11-2.0.so.0 [0xb6d56a7c]
>     /usr/lib/libgtk-x11-2.0.so.0 [0xb6cb5b38]
>     /usr/lib/libgobject-2.0.so.0 [0xb6956079]
>     /usr/lib/libgobject-2.0.so.0(g_closure_invoke+0x1ff) [0xb695782f]
>     /usr/lib/libgobject-2.0.so.0 [0xb696c11a]
>     /usr/lib/libgobject-2.0.so.0(g_signal_emit_valist+0x8ef)
> [0xb696dc1f]
>     /usr/lib/libgobject-2.0.so.0(g_signal_emit+0x29) [0xb696df69]
>     /usr/lib/libgtk-x11-2.0.so.0 [0xb6d51422]
>     /usr/lib/libgtk-x11-2.0.so.0(gtk_text_buffer_set_text+0xbe)
> [0xb6d5254e]
>     /usr/lib/libgobject-2.0.so.0(g_object_set_property+0x403)
> [0xb695eb13]
>     [0xb664c759]
>     [0xb664c654]
>     [0xb407f2da]
>     [0xb407f526]
>     [0xb6651733]
>     [0xb66490d8]
>     /usr/lib/libgobject-2.0.so.0(g_cclosure_marshal_VOID__VOID+0x4f)
> [0xb6964aff]
>     /usr/lib/libgobject-2.0.so.0(g_closure_invoke+0x1ff) [0xb695782f]
>     /usr/lib/libgobject-2.0.so.0 [0xb696c329]
>     /usr/lib/libgobject-2.0.so.0(g_signal_emit_valist+0x8ef)
> [0xb696dc1f]
>     /usr/lib/libgobject-2.0.so.0(g_signal_emit+0x29) [0xb696df69]
>     /usr/lib/libgtk-x11-2.0.so.0 [0xb6d56a7c]
>     /usr/lib/libgtk-x11-2.0.so.0 [0xb6cb5b38]
>     /usr/lib/libgobject-2.0.so.0 [0xb6956079]
>     /usr/lib/libgobject-2.0.so.0(g_closure_invoke+0x1ff) [0xb695782f]
>     /usr/lib/libgobject-2.0.so.0 [0xb696c11a]
>     /usr/lib/libgobject-2.0.so.0(g_signal_emit_valist+0x8ef)
> [0xb696dc1f]
>     /usr/lib/libgobject-2.0.so.0(g_signal_emit+0x29) [0xb696df69]
>     /usr/lib/libgtk-x11-2.0.so.0 [0xb6d51422]
>     /usr/lib/libgtk-x11-2.0.so.0(gtk_text_buffer_set_text+0xbe)
> [0xb6d5254e]
>     /usr/lib/libgobject-2.0.so.0(g_object_set_property+0x403)
> [0xb695eb13]
>     [0xb664c759]
>     [0xb664c654]
>     [0xb407f2da]
>     [0xb407f526]
>     [0xb6651733]
>     [0xb66490d8]
>     /usr/lib/libgobject-2.0.so.0(g_cclosure_marshal_VOID__VOID+0x4f)
> [0xb6964aff]
>     /usr/lib/libgobject-2.0.so.0(g_closure_invoke+0x1ff) [0xb695782f]
>     /usr/lib/libgobject-2.0.so.0 [0xb696c329]
>     /usr/lib/libgobject-2.0.so.0(g_signal_emit_valist+0x8ef)
> [0xb696dc1f]
>     /usr/lib/libgobject-2.0.so.0(g_signal_emit+0x29) [0xb696df69]
> ---------------------------------------------------
> So any ideas?
> Regards
> On Thu, Sep 25, 2008 at 9:27 PM, True Friend
> <true.friend2004 at gmail.com> wrote:
>         Thanks. After trying different events finally I added it to
>         filesave event handler. I'll try this as well.
>         Regards
>         
>         
>         
>         On Thu, Sep 25, 2008 at 9:22 PM, Chris Howie
>         <cdhowie at gmail.com> wrote:
>                 On Thu, Sep 25, 2008 at 7:00 AM, True Friend
>                 <true.friend2004 at gmail.com> wrote:
>                 > HI
>                 > I am working on a simple application. I had same in
>                 winforms where I added
>                 > above (in subject) said event handler so when I
>                 pasted some text or text
>                 > changed in rich text box the method was called and
>                 it made some
>                 > modifications in text. Can you tell me what is its
>                 equal in gtk? I tried to
>                 > search textview events but couldn't find an
>                 appropriate one which can work
>                 > as textchanged event...
>                 
>                 
>                 Much of GTK+ uses the MVC (Model, View, and
>                 Controller) model.  In
>                 this case, TextView is the view and TextBuffer is the
>                 model.  The
>                 changed event is on the TextBuffer, so:
>                 
>                 this.someTextView.Buffer.Changed +=
>                 this.OnSomeTextViewChanged;
>                 
>                 --
>                 Chris Howie
>                 http://www.chrishowie.com
>                 http://en.wikipedia.org/wiki/User:Crazycomputers
>         
>         
>         
>         
>         -- 
>         Muhammad Shakir Aziz محمد شاکر عزیز
>         
>         
> 
> 
> 
> -- 
> Muhammad Shakir Aziz محمد شاکر عزیز
> 
> 
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list



More information about the Gtk-sharp-list mailing list