NAME
Prima::InputLine - input line widget
SYNOPSIS
use Prima qw(InputLine Application);
Prima::InputLine-> new( text => 'Hello world!');
run Prima;
DESCRIPTION
The class provides the basic functionality of an input line, including hidden input, read-only state, selection, and clipboard operations. The input line text data is stored in the text property.
API
Events
- Change
-
The notification is called when the text property is changed, either interactively or as a result of a direct call.
- Validate TEXT_REF
-
The notification is called right before the text property is changed, either interactively or as a result of a direct call. The custom code has a chance to validate the text and/or provide some sort of interactive feedback.
See also: "blink"
Properties
- alignment INTEGER
-
One of the following
ta::
constants, defining the text alignment:ta::Left ta::Right ta::Center
Default value:
ta::Left
- autoHeight BOOLEAN
-
If 1, adjusts the height of the widget automatically when its font changes.
Default value: 1
- autoSelect BOOLEAN
-
If 1, all the text is selected when the widget becomes focused.
Default value: 1
- autoTab BOOLEAN
-
If 1, ignores the keyboard
kb::Left
andkb::Right
commands, when these are received when the cursor is at the beginning or the end of text and cannot be moved farther. The result of this is that the default handler moves focus to a neighbor widget, in a way as if the Tab key was pressed.Default value: 0
- borderWidth INTEGER
-
Width of the border around the widget.
Default value: depends on the skin
- charOffset INTEGER
-
Managets the current position of the cursor
- firstChar
-
Selects the first visible cluster of text
- insertMode BOOLEAN
-
Manages the typing mode - if 1, the typed text is inserted, if 0, the text overwrites the old text. When
insertMode
is 0 the cursor shape is thick and covers the whole character; when 1, it is of the default width.Default toggle key: Insert
- maxLen INTEGER
-
The maximal length of the text, that can be stored into text or typed by the user.
Default value: 256
- passwordChar CHARACTER
-
A character to be shown instead of the text letters when writeOnly property value is 1.
Default value:
'*'
- readOnly BOOLEAN
-
If 1, the text cannot be edited by the user.
Default value: 0
- selection START, END
-
Two integers, specifying the beginning and the end of the selected text, in clusters. A case with no selection is when START equals END.
- selStart INTEGER
-
Selects the start of the text selection.
- selEnd INTEGER
-
Selects the end of the text selection.
- textDirection BOOLEAN
-
If set, indicates RTL text input.
- textLigation BOOLEAN
-
If set, text may be rendered at better quality with ligation and kerning, however, that comes with a price that some ligatures may be indivisible and form clusters (f.ex. ff or ffi ligatures). The cursor cannot go inside such clusters, and thus one can only select them, delete them as a whole, or press Del/Backspace on the cluster's edge.
Toggle during runtime with Ctrl+Shift+L.
- wordDelimiters STRING
-
Contains the string of characters that are used for locating a word break. Default STRING value consists of punctuation marks, space, tab, and
\xff
character. - writeOnly BOOLEAN
-
If 1, the input is not shown but mapped to passwordChar characters. Useful for a password entry.
Default value: 0
Methods
- blink %options
-
Produces a short blink by setting the background to red color. Can be used to signal an invalid input, f ex from
on_validate
.%options
allows thebackColor
andcolor
entries. - copy
-
Copies the selected text, if any, to the clipboard.
Default key: Ctrl+Insert and Ctrl+C
- cut
-
Cuts the selected text into the clipboard.
Default key: Shift+Delete and Ctrl+X
- delete
-
Removes the selected text.
Default key: Delete
- paste
-
Copies text from the clipboard and inserts it in the cursor position.
Default key: Shift+Insert and Ctrl+V
- select_all
-
Selects all text
Bi-directional input and output
When working on bidirectional texts, or text represented by complex script shaping, values returned from the methods firstChar
, charOffset
, selection
, etc cannot be used to calculate text offsets f.ex. via substr
. Note that these values are in clusters, not in characters (see Prima::Drawable::Glyphs for the description>. Also, the selection ranges of bidi text become not straightforward. Use the following methods whenever text manipulations are needed:
- char_at OFFSET
-
Returns character at cluster OFFSET
- selection_strpos
-
Returns range of characters covered by the selection.
AUTHOR
Dmitry Karasik, <dmitry@karasik.eu.org>.
SEE ALSO
Prima, Prima::Widget, examples/edit.pl.