This is the FLTK text input widget. It displays a single line
of text and lets the user edit it. Normally it is drawn with an
inset box and a white background. The text may contain any
characters (even 0), and will correctly display anything, using
^X notation for unprintable control characters and \nnn notation
for unprintable characters with the high bit set. It assumes the
font can draw any characters in the ISO-8859-1 character set.
|Mouse button 1||Moves the cursor to
this point. Drag selects characters. Double click selects words.
Triple click selects all text. Shift+click extends the selection.
When you select text it is automatically copied to the clipboard.
|Mouse button 2||Insert the clipboard at
the point clicked. You can also select a region and replace it with the
clipboard by selecting the region with mouse button 2.
|Mouse button 3||Currently acts like button 1.|
|Backspace||Deletes one character to the left, or
deletes the selected region.|
|Enter||May cause the callback, see when().|
|^A or Home||Go to start of line.|
|^B or Left||Move left|
|^C||Copy the selection to the clipboard|
|^D or Delete||Deletes one character to the right
or deletes the selected region.|
|^E or End||Go to the end of line.|
|^F or Right||Move right|
|^K||Delete to the end of line (next \n character)
or deletes a single \n character. These deletions are all concatenated
into the clipboard.|
|^N or Down||Move down (for Fl_Multiline_Input
only, otherwise it moves to the next input field).|
|^P or Up||Move up (for Fl_Multiline_Input only,
otherwise it moves to the previous input field).|
|^V or ^Y||Paste the clipboard|
|^X or ^W||Copy the region to the clipboard and
|^Z or ^_||Undo. This is a single-level undo
mechanism, but all adjacent deletions and insertions are concatenated
into a single "undo". Often this will undo a lot more than you
|Shift+move||Move the cursor but also extend the
sequence. The next one or two keys typed define the character to
insert (see table that follows.)
For instance, to type "á" type [compose][a]['] or [compose]['][a].
The character "nbsp" (non-breaking space) is typed by using
The single-character sequences may be followed by a space if
necessary to remove ambiguity. For instance, if you really want to
type "ª~" rather than "ã" you must type [compose][a][space][~].
The same key may be used to "quote" control characters into the
text. If you need a ^Q character you can get one by typing
X may have a key on the keyboard
defined as XK_Multi_key. If so this key may be used as well
as the right-hand control key. You can set this up with the program
If your keyboard is set to support a foreign language you should
also be able to type "dead key" prefix characters. On X you will
actually be able to see what dead key you typed, and if you then move
the cursor without completing the sequence the accent will remain
Character Composition Table
Creates a new Fl_Input widget using the given position, size,
and label string. The default boxtype is FL_DOWN_BOX.
Destroys the widget and any value associated with it.
The first form returns the current value, which is a pointer
to the internal buffer and is valid only until the next event is
The second two forms change the text and set the mark and the
point to the end of it. The string is copied to the internal
buffer. Passing NULL is the same as "".
This returns non-zero if the new value is different than the
current one. You can use the second version to directly set the
length if you know it already or want to put nul's in the
Change the text and set the mark and the point to the end of
it. The string is not copied. If the user edits the
string it is copied to the internal buffer then. This can save a
great deal of time and memory if your program is rapidly
changing the values of text fields, but this will only work if
the passed string remains unchanged until either the
Fl_Input is destroyed or value() is called
Returns the number of characters in value(). This
may be greater than strlen(value()) if there are nul
characters in it.
Same as value()[n], but may be faster in plausible
implementations. No bounds checking is done.
Controls when callbacks are done. The following values are useful,
the default value is FL_WHEN_RELEASE:
- 0: The callback is not done, but
changed() is turned on.
- FL_WHEN_CHANGED: The callback is done each
time the text is changed by the user.
- FL_WHEN_RELEASE: The callback will be done
when this widget loses the focus, including when the
window is unmapped. This is a useful value for text
fields in a panel where doing the callback on every
change is wasteful. However the callback will also
happen if the mouse is moved out of the window, which
means it should not do anything visible (like pop up an
error message). You might do better setting this to
zero, and scanning all the items for changed()
when the OK button on a panel is pressed.
- FL_WHEN_ENTER_KEY: If the user types the
Enter key, the entire text is selected, and the callback
is done if the text has changed. Normally the Enter key
will navigate to the next field (or insert a newline for
a Fl_Mulitline_Input), this changes the
- FL_WHEN_ENTER_KEY|FL_WHEN_NOT_CHANGED: The
Enter key will do the callback even if the text has not
changed. Useful for command fields.
Gets or sets the color of the text in the input field.
Gets or sets the font of the text in the input field.
Gets or sets the size of the text in the input field.
Get or set the color of the cursor. This is black by default.
From pdbogen, 12:25 Oct 14, 2005 (score=3)
Is there a way for the callback to detect whether it was called because of a change or because of an enter press? (with input->when( FL_WHEN_ENTER_KEY|FL_WHEN_NOT_CHANGED ) )
[ Reply ]
From greg.ercolano, 15:52 Apr 23, 2007 (score=3)
Yes, I think the above description for when() covers that exact question.
I was just writing some code now where I wanted the enter key to invoke the callback whether the text changed or not, and it works as advertised.
The docs for this goes back to 1.1.3 [released circa 2003?], so they've been in there for a while.
[ Reply ]