Creates an editable text field.
Ihandle* IupText(const char *action); [in C]
iup.text{} -> (ih: ihandle) [in Lua]
text(action) [in LED]
action: name of the action generated when the user types something. It can be NULL.
Returns: the identifier of the created element, or NULL if an error occurs.
ALIGNMENT [Windows and GTK Only] (non inheritable): horizontal text alignment. Possible values: "ALEFT", "ARIGHT", "ACENTER". Default: "ALEFT". In Motif, text is always left aligned.
APPEND (write-only): Inserts a text at the end of the current text. In the Multiline, if APPENDNEWLINE=YES, a "\n" character will be automatically inserted before the appended text if the current text is not empty(APPENDNEWLINE default is YES). Ignored if set before map.
BGCOLOR: Background color of the text. Default: the global attribute TXTBGCOLOR. Ignored in GTK when MULTILINE=NO.
BORDER (creation only): Shows a border around the text. Default: "YES".
CANFOCUS (creation only) (non inheritable): enables the focus traversal of the control. In Windows the control will still get the focus when clicked. Default: YES. (since 3.0)
PROPAGATEFOCUS(non inheritable): enables the focus callback forwarding to the next native parent with FOCUS_CB defined. Default: NO. (since 3.23)
CARET (non inheritable): Character position of the insertion point. Its format depends in MULTILINE=YES. The first position, lin or col, is "1".
For multiple lines: a string with the "lin,col" format, where lin and col are integer numbers corresponding to the caret's position.
For single line: a string in the "col" format, where col is an integer number corresponding to the caret's position.
When lin is greater than the number of lines, the caret is placed at the last line. When col is greater than the number of characters in the given line, the caret is placed after the last character of the line.
If the caret is not visible the text is scrolled to make it visible.
In Windows, if the element does not have the focus the returned value is the position of the first character of the current selection. The caret is only displayed if the element has the keyboard focus, but its position can be changed even if not visible. When changed it will also change the selection but the text will be scrolled only when it receives the focus.
See the Notes below if using UTF-8 strings in GTK.
CARETPOS (non inheritable): Also the character position of the insertion point, but using a zero based character unique index "pos". Useful for indexing the VALUE string. See the Notes below if using UTF-8 strings in GTK. (since 3.0)
CHANGECASE (non inheritable): Change case according to given conversion. Can be UPPER, LOWER, TOGGLE, or TITLE. TITLE case change first letter of words separated by spaces to upper case others to lower case, but first letter is changed only if word has more than 3 characters, for instance: "Best of the World". Supports Latin-1 encoding only, even when using UTF-8. Does not depends on current locale. (since 3.28)
CLIPBOARD (write-only): clear, cut, copy or paste the selection to or from the clipboard. Values: "CLEAR", "CUT", "COPY" or "PASTE". In Windows UNDO is also available, and REDO is available when FORMATTING=YES. (since 3.0)
COUNT (read-only): returns the number of characters in the text, including the line breaks. (since 3.5)
CUEBANNER [Windows and GTK Only] (non inheritable): a text that is displayed when there is no text at the control. It works as a textual cue, or tip to prompt the user for input. Valid only for MULTILINE=NO, and works only when Visual Styles are enabled. (since 3.0) [GTK 3.2] (GTK support added in IUP 3.20)
DROPFILESTARGET [Windows and GTK Only] (non inheritable): Enable or disable the drop of files. Default: NO, but if DROPFILES_CB is defined when the element is mapped then it will be automatically enabled. (since 3.0)
FGCOLOR: Text color. Default: the global attribute TXTFGCOLOR.
FILTER [Windows Only] (non inheritable): allows a custom filter to process the characters: Can be LOWERCASE, UPPERCASE or NUMBER (only numbers allowed). (since 3.0)
FORMATTING [Windows and GTK Only] (non inheritable): When enabled allow the use of text formatting attributes. In GTK is always enabled, but only when MULTILINE=YES. Default: NO. (since 3.0)
INSERT (write-only): Inserts a text in the caret's position, also replaces the current selection if any. Ignored if set before map.
LINECOUNT (read-only): returns the number of lines in the text. When MULTILINE=NO returns always "1". (since 3.5)
LINEVALUE (read-only): returns the text of the line where the caret is. It does not include the "\n" character. When MULTILINE=NO returns the same as VALUE. (since 3.5)
LOADRTF (write-only) [Windows Only]: loads formatted text from a Rich Text Format file given its filename. The attribute LOADRTFSTATUS is set to OK or FAILED after the file is loaded. (since 3.28)
SAVERTF (write-only) [Windows Only]: saves formatted text to a Rich Text Format file given its filename. The attribute SAVERTFSTATUS is set to OK or FAILED after the file is saved. (since 3.28)
MASK (non inheritable): Defines a mask that will filter interactive text input.
MULTILINE (creation only) (non inheritable): allows the edition of multiple lines. In single line mode some characters are invalid, like "\t", "\r" and "\n". Default: NO. When set to Yes will also reset the SCROLLBAR attribute to Yes.
NC: Maximum number of characters allowed for keyboard input, larger text can still be set using attributes. The maximum value is the limit of the VALUE attribute. The "0" value is the same as maximum. Default: maximum.
NOHIDESEL [Windows Only]: do not hide the selection when the control loses its focus. Default: Yes. (since 3.16)
OVERWRITE [Windows and GTK Only] (non inheritable): turns the overwrite mode ON or OFF. Works only when FORMATTING=YES. (since 3.0)
PADDING: internal margin. Works just like the MARGIN attribute of the IupHbox and IupVbox containers, but uses a different name to avoid inheritance problems. Default value: "0x0". In Windows, only the horizontal value is used. (since 3.0) (GTK 2.10 for single line)
CPADDING: same as PADDING but using the units of the SIZE attribute. It will actually set the PADDING attribute. (since 3.29)
PASSWORD (creation only) [Windows and GTK Only] (non inheritable): Hide the typed character using an "*". Default: "NO".
READONLY: Allows the user only to read the contents, without changing it. Restricts keyboard input only, text value can still be changed using attributes. Navigation keys are still available. Possible values: "YES", "NO". Default: NO.
SCROLLBAR (creation only): Valid only when MULTILINE=YES. Associates an automatic horizontal and/or vertical scrollbar to the multiline. Can be: "VERTICAL", "HORIZONTAL", "YES" (both) or "NO" (none). Default: "YES". For all systems, when SCROLLBAR!=NO the natural size will always include its size even if the native system hides the scrollbar. If AUTOHIDE=YES scrollbars are visible only if they are necessary, by default AUTOHIDE=NO. In Windows when FORMATTING=NO, AUTOHIDE is not supported. In Motif AUTOHIDE is not supported.
SCROLLTO (non inheritable, write only): Scroll the text to make the given character position visible. It uses the same format and reference of the CARET attribute ("lin:col" or "col" starting at 1). In Windows, when FORMATTING=Yes "col" is ignored. (since 3.0)
SCROLLTOPOS (non inheritable, write only): Scroll the text to make the given character position visible. It uses the same format and reference of the CARETPOS attribute ("pos" starting at 0). (since 3.0)
SCROLLVISIBLE (read-only) [Windows Only]: Returns which scrollbars are visible at the moment. Can be: YES (both), VERTICAL, HORIZONTAL, NO. (since 3.31)
SELECTEDTEXT (non inheritable): Selection text. Returns NULL if there is no selection. When changed replaces the current selection. Similar to INSERT, but does nothing if there is no selection.
SELECTION (non inheritable): Selection interval in characters. Returns NULL if there is no selection. Its format depends in MULTILINE=YES. The first position, lin or col, is "1".
For multiple lines: a string in the "lin1,col1:lin2,col2" format, where lin1, col1, lin2 and col2 are integer numbers corresponding to the selection's interval. col2 correspond to the character after the last selected character.
For single line: a string in the "col1:col2" format, where col1 and col2 are integer numbers corresponding to the selection's interval. col2 correspond to the character after the last selected character.
In Windows, when changing the selection the caret position is also changed.
The values ALL and NONE are also accepted independently of MULTILINE (since 3.0).
See the Notes below if using UTF-8 strings in GTK.
SELECTIONPOS (non inheritable): Same as SELECTION but using a zero based character index "pos1:pos2". Useful for indexing the VALUE string. The values ALL and NONE are also accepted. See the Notes below if using UTF-8 strings in GTK. (since 3.0)
SIZE (non inheritable): Since the contents can be changed by the user, the Natural Size is not affected by the text contents (since 3.0). Use VISIBLECOLUMNS and VISIBLELINES to control the Natural Size.
SPIN (non inheritable, creation only): enables a spin control attached to the element. Default: NO. The spin increments and decrements an integer number. The editing in the element is still available. (since 3.0)
SPINVALUE (non inheritable): the current value of the spin. The
value is limited to the minimum and maximum values.
SPINMAX (non inheritable): the maximum value. Default: 100.
SPINMIN (non inheritable): the minimum value. Default: 0.
SPININC (non inheritable): the increment value. Default: 1.
SPINALIGN (creation only): the position of the spin. Can be LEFT or RIGHT.
Default: RIGHT. In GTK is always RIGHT.
SPINWRAP (creation only): if the position reach a limit it continues from the
opposite limit. Default: NO.
SPINAUTO (creation only): enables the automatic update of the text contents.
Default: YES. Use SPINAUTO=NO and the VALUE attribute during SPIN_CB to control
the text contents when the spin is incremented.
In Windows, the increment is multiplied by 5 after 2 seconds and multiplied by 20 after 5 seconds of a spin button pressed. In GTK, the increment change is progressively accelerated when a spin button is pressed.
TABSIZE [Windows and GTK Only]: Valid only when MULTILINE=YES. Controls the number of characters for a tab stop. Default: 8.
VALUE (non inheritable): Text entered by the user. The '\n' character indicates a new line, valid only when MULTILINE=YES. After the element is mapped and if there is no text will return the empty string "".
VALUEMASKED (non inheritable) (write-only): sets VALUE but first checks if it is validated by MASK. If not does nothing. (since 3.4)
VISIBLECOLUMNS: Defines the number of visible columns for the Natural Size, this means that will act also as minimum number of visible columns. It uses a wider character size than the one used for the SIZE attribute so strings will fit better without the need of extra columns. As for SIZE you can set to NULL after map to use it as an initial value. Default: 5 (since 3.0)
VISIBLELINES: When MULTILINE=YES defines the number of visible lines for the Natural Size, this means that will act also as minimum number of visible lines. As for SIZE you can set to NULL after map to use it as an initial value. Default: 1 (since 3.0)
WORDWRAP (creation only): Valid only when MULTILINE=YES. If enabled will force a word wrap of lines that are greater than the with of the control, and the horizontal scrollbar will be removed. Default: NO.
ACTIVE, FONT, EXPAND, SCREENPOSITION, POSITION, MINSIZE, MAXSIZE, WID, TIP, RASTERSIZE, ZORDER, VISIBLE, THEME: also accepted.
Drag & Drop attributes are supported. See Notes bellow.
ACTION: Action generated when the text is edited, but before its value is actually changed. Can be generated when using the keyboard, undo system or from the clipboard.
int function(Ihandle *ih, int c, char *new_value); [in C]
ih:action(c: number, new_value: string) -> (ret: number) [in Lua]
ih:
identifier of the element that activated the
event.
c: valid alpha numeric character or 0.
new_value:
Represents the new text value.
Returns: IUP_CLOSE will be processed, but the change will be ignored. If IUP_IGNORE, the system will ignore the new value. If c is valid and returns a valid alpha numeric character, this new character will be used instead. The VALUE attribute can be changed only if IUP_IGNORE is returned.
BUTTON_CB: Action generated when any mouse button is pressed or released. Use IupConvertXYToPos to convert (x,y) coordinates in character positioning. (since 3.0)
CARET_CB: Action generated when the caret/cursor position is changed.
int function(Ihandle *ih, int lin, int col, int pos); [in C]
ih:caret_cb(lin, col, pos: number) -> (ret: number) [in Lua]
ih:
identifier of the element that activated the
event.
lin, col: line and column number (start at 1).
pos: 0 based character position.
For single line controls lin is always 1, and pos is always "col-1".
DROPFILES_CB [Windows and GTK Only]: Action generated when one or more files are dropped in the element. (since 3.0)
MOTION_CB: Action generated when the mouse is moved. Use IupConvertXYToPos to convert (x,y) coordinates in character positioning. (since 3.0)
SPIN_CB: Action generated when a spin button is pressed. Valid only when SPIN=YES. When this callback is called the ACTION callback is not called. The VALUE attribute can be changed during this callback only if SPINAUTO=NO. (since 3.0)
int function(Ihandle *ih, int pos); [in C]
ih:spin_cb(pos: number) -> (ret: number) [in Lua]
ih:
identifier of the element that activated the
event.
pos: the value of the spin (after it was incremented).
Returns: IUP_IGNORE is processed in Windows and Motif.
VALUECHANGED_CB: Called after the value was interactively changed by the user. (since 3.0)
int function(Ihandle *ih); [in C]
ih:valuechanged_cb() -> (ret: number) [in Lua]
ih: identifier of the element that activated the event.
MAP_CB, UNMAP_CB, DESTROY_CB, GETFOCUS_CB, KILLFOCUS_CB, ENTERWINDOW_CB, LEAVEWINDOW_CB, K_ANY, HELP_CB: All common callbacks are supported.
Drag & Drop callbacks are supported. See Notes bellow.
void IupTextConvertLinColToPos(Ihandle* ih, int lin, int col, int *pos); [in C]
iup.TextConvertLinColToPos(ih: ihandle, lin, col: number) -> pos: number [in Lua]
Converts a (lin, col) character positioning into an absolute position. lin and col starts at 1, pos starts at 0. For single line controls pos is always "col-1". (since 3.0)
void IupTextConvertPosToLinCol(Ihandle* ih, int pos, int *lin, int *col); [in C]
iup.TextConvertPosToLinCol(ih: ihandle, pos: number) -> lin, col: number [in Lua]
Converts an absolute position into a (lin, col) character positioning. lin and col starts at 1, pos starts at 0. For single line controls lin is always 1, and col is always "pos+1". (since 3.0)
When MULTILINE=YES the Enter key will add a new line, and the Tab key will insert a Tab. So the "DEFAULTENTER" button will not be processed when the element has the keyboard focus, also to change focus to the next element press <Ctrl>+<Tab>.
In Windows, if you press a Ctrl+key combination that is not supported by the control, then a beep is sound.
When using UTF-8 strings in GTK be aware that all attributes are indexed by characters, NOT by byte index, because some characters in UTF-8 can use more than one byte. This also applies to Windows if FORMATTING=YES depending on the Windows codepage (for example East Asian codepage where some characters take two bytes).
Internal Drag&Drop support is enabled by default. But in Windows the internal Drag&Drop is enabled only if FORMATTING=YES. In GTK the internal Drag&Drop can NOT be disabled, so it will conflict with the Drag & Drop attributes and callbacks.
In GTK uses GtkTextView/GtkEntry/GtkSpinButton, in Windows uses RICHEDIT_CLASS (formatting)/WC_EDIT, and in Motif uses xmText/xmTextField, for Single/Multiline.
Here is a list of the common keys for all drivers. Other keys are available depending on the driver.
Keys | Action |
---|---|
Navigation | |
Arrows | move by individual characters/lines |
Ctrl+Arrows | move by words/paragraphs |
Home/End | move to begin/end line |
Ctrl+Home/End | move to begin/end text |
PgUp/PgDn | move vertically by pages |
Ctrl+PgUp/PgDn | move horizontally by pages |
Selection | |
Shift+Arrows | select charaters |
Ctrl+A | select all |
Deleting | |
Del | delete the character at right |
Backspace | delete the character at left |
Clipboard | |
Ctrl+C | copy |
Ctrl+X | cut |
Ctrl+V | paste |
Motif | Windows Classic |
Windows w/ Styles |
GTK |
---|---|---|---|
When FORMATTING=YES in Windows or GTK (formatting attributes are set to a formatag object that it is a IupUser):
"ALIGNMENT" = "CENTER" |
When SPIN=YES:
Motif | Windows Classic |
Windows w/ Styles |
GTK |
---|---|---|---|