Gtk2::Ex::EntryBits -- misc functions for Gtk2::Entry widgets
Gtk2::Ex::EntryBits::select_region_noclip ($entry, $start, $end)
Select text from
$entry->select_region, but don't put it on the clipboard. This is a good way to let the user type over previous text, without upsetting any cut and paste in progress.
This is implemented with a nasty hack temporarily pretending
$pos = Gtk2::Ex::EntryBits::x_to_text_index ($entry, $x)
$entrywidget coordinates to a character index into the text string in the entry.
$xis past the beginning of the text the return is 0. If
$xis past the end of the text the return is length(text). Any xalign or user scrolling is accounted for so the character position is as the text appears on screen.
This is implemented by pango layout offset as described in the GtkEntry
$event_ret = Gtk2::Ex::EntryBits::scroll_number_handler ($entry, $event)
This function can be used as a handler for the
scroll-eventsignal of a
Gtk2::Entryto have a mouse scroll increment or decrement numbers within the entry text.
+-----------------+ | abc,123+def*56 | +-----------------+ ^ ^ scroll with mouse over a number to increment/decrement
$event->direction()is "up" or "down" and the mouse
$event->x()position is over a number then increment or decrement that number by 1, or if the control key (
$event->state) is held down then by 10.
The return value is
Gtk2::EVENT_STOPif a number is scrolled, or
Gtk2::EVENT_PROPAGATEif not (either "left" or "right" scrolls or not over a number).
Nothing is exported by default, but the functions can be requested in usual
use Gtk2::Ex::EntryBits 'x_to_text_index'; $pos = x_to_text_index ($entry, $x);
The names are probably a bit too generic to want to import most of the time, but might suit an Entry subclass or something only Entry related.
:all tag since this module is meant as a grab-bag of functions and to import as-yet unknown things would be asking for name clashes.
Copyright 2007, 2008, 2009, 2010, 2011, 2012 Kevin Ryde
Gtk2-Ex-WidgetBits is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Gtk2-Ex-WidgetBits is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Gtk2-Ex-WidgetBits. If not, see http://www.gnu.org/licenses/.