NAME

Gtk2::Ex::EntryBits -- misc functions for Gtk2::Entry widgets

SYNOPSIS

use Gtk2::Ex::EntryBits;

FUNCTIONS

Gtk2::Ex::EntryBits::select_region_noclip ($entry, $start, $end)

Select text from $start to $end like $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 $entry is unrealized.

$pos = Gtk2::Ex::EntryBits::x_to_text_index ($entry, $x)

Convert from $x pixel in $entry widget coordinates to a character index into the text string in the entry.

If $x is past the beginning of the text the return is 0. If $x is 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 gtk_entry_get_layout_offsets() documentation.

$event_ret = Gtk2::Ex::EntryBits::scroll_number_handler ($entry, $event)

This function can be used as a handler for the scroll-event signal of a Gtk2::Entry to 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

If $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_STOP if a number is scrolled, or Gtk2::EVENT_PROPAGATE if not (either "left" or "right" scrolls or not over a number).

EXPORTS

Nothing is exported by default, but the functions can be requested in usual Exporter style,

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.

There's no :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.

SEE ALSO

Gtk2::Entry, Gtk2::Editable

HOME PAGE

http://user42.tuxfamily.org/gtk2-ex-widgetbits/index.html

LICENSE

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/.