[Gtk-sharp-list] Gtk entry autocomplete

Sergio Rubio sergio.rubio@hispalinux.es
Tue, 14 Sep 2004 21:52:49 +0200


Thanks Freon, but I have finally found it. It seems that the better
aproach is to use Gtk.Widget.OnKeyPressEvent instead of any of the Entry
event handlers I was using before. They were driving me crazy. Here is
the code snippet of my CompletionEntry widget:

protected override bool OnKeyPressEvent (Gdk.EventKey evt)
{
            base.OnKeyPressEvent (evt);
            if ((evt.Key == Gdk.Key.BackSpace) || 
		(evt.Key == Gdk.Key.Escape))
                return false;
            DeleteSelection ();
            //Fake speed
            if (Text.Length > 2)
            {
                string bin = AutoComplete (Text);
                if (bin != null)
                {
                    int oldLength = Text.Length;
                    Text = bin;
                    SelectRegion (oldLength, Text.Length);
                }
            }
            return true;
        }
}

Anyway, thanks again.

On Tue, 2004-09-14 at 21:03 +0200, Freon wrote:
> Well, I was working on something like that some time ago. I had a
> basic version ruinning in no time. Then I made something stupid and
> had a look at the Monodevelop autocompletion code and decided to
> implement something similar.
> 
> Anyway, I have something I can send you, but it's not finished, and
> it's commented in french :D
> You may want to have a look at the monodoc version instead (located
> under monodevelop-0.5/src/AddIns/DisplayBindings/SourceEditor/CodeCompletion)
> since my code was heavily based on that. The only difference is that
> it was made for a TextView.
> 
> On Tue, 14 Sep 2004 20:08:10 +0200, Sergio Rubio
> <sergio.rubio@hispalinux.es> wrote:
> > Hi,
> > 
> > I'm having real headaches trying to implement an autocompletable
> > Gtk.Entry (It seems that I don't understand the gtk-sharp/gtk event
> > model yet). I know that this stuff is included in gtk2.4 but I would
> > like to have it with the current version of gtk-sharp. Does someone have
> > this kind of widget? The piece of my brain that I need to implement this
> > is missing.
> > 
> > Cheers,
> > Rubio.
> > --
> > 
> > ::: sergio.rubio@hispalinux.es :::
> > ::: http://mspace.berlios.de   :::
> > ::: rubiojr@jabber.org         :::
> > 
> > _______________________________________________
> > Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
> >
-- 

::: sergio.rubio@hispalinux.es :::
::: http://mspace.berlios.de   :::
::: rubiojr@jabber.org         :::