Example #1
0
        public static string GetSelectedText(this Gtk.Entry entry)
        {
            int start;
            int end;

            entry.GetSelectionBounds(out start, out end);
            return(entry.Text.Substring(start, end - start));
        }
Example #2
0
        public static bool ReplaceSelection(this Gtk.Entry entry, string newText)
        {
            bool retval = false;
            int  start;
            int  end;

            if (entry.GetSelectionBounds(out start, out end) || start == end)
            {
                entry.Text = string.Format("{0}{1}{2}", entry.Text.Substring(0, start), newText, entry.Text.Substring(end));
                retval     = true;

                entry.Position = start + newText.Length;
            }


            return(retval);
        }