class Iup::Text
A text control is one of the more complex controls, because it can be displayed in a variety of ways:
(1) a single line, for inputting a single line of text.
Iup::Text.new do |t| t.expand = 'horizontal' end
(2) a multi-line control, to act more like an editor.
Iup::Text.new do |t| t.multiline = 'yes' t.expand = 'yes' t.size = '200x100' end
(3) a spin box, for selecting one of several values: this example supports the range 10 to 20 and reports the current value as it changes.
Iup::Text.new do |t| t.spin = 'yes' t.spinmax = 20 t.spinmin = 10 t.expand = 'horizontal' t.spin_cb = ->(v){ puts "spin control is now #{v}" Iup::DEFAULT } end
Attributes
Sets the alignment of text within control, options ‘ALEFT’ / ‘ACENTER’ / ‘ARIGHT’.
Appends given string to end of text.
If set, scrollbars are only shown if necessary, values ‘yes’ / ‘no’.
Sets border around text, values ‘yes’ / ‘no’.
If set, the control can gain focus, values ‘yes’ / ‘no’.
Character position of insertion point: + ‘col’ in single-line mode, sets column number of caret; + ‘lin,col’ in multi-line mode, sets line and column number of caret.
Index of character of the insertion point: uses a 0-based index of entire text value.
‘clear’ / ‘copy’ / ‘cut’ / ‘paste’, access the clipboard with the current selection.
Number of characters and line-breaks in text.
Allows control to fill available space in indicated direction. Values ‘no’ / ‘horizontal’ / ‘vertical’ / ‘yes’.
Set to ‘yes’ in multi-line mode, to allow control to use formatting of text.
Places a given string at current caret position, overwriting any current selection.
Returns number of lines of text.
Returns line of text where the caret is.
Defines a mask to filter text input. See pre-defined masks.
Set multiline text input, values ‘no’ / ‘yes’.
Maximum number of characters allowed for keyboard input (0 allows an indefinite number).
‘off’ / ‘on’, used when formatting=yes.
Margin in x and y directions, value as “mxn”.
‘yes’ / ‘no’, if set, masks the input text as “*”.
Returns position in pixels within client window as “x,y”.
Size in pixels within client window, value as “widthxheight”.
User cannot change the contents, values ‘yes’ / ‘no’.
Returns position in pixels on screen as “x,y”.
In multi-line mode, selects ‘no’ / ‘horizontal’ / ‘vertical’ / ‘yes’ (for both) scrollbars.
-
‘col’ Scrolls to make given column number visible, in single-line mode.
-
‘lin/col’ Scrolls to make line and column number visible, in multi-line mode.
Scrolls to make character ‘number’ visible.
Reads or overwrites the current selection. Does nothing if no text is selected.
Selects text as ‘col1:col2’ (single-line) / ‘lin1,col1:lin2,col2’ (multi-line) / ‘all’ / ‘none’.
Selects text between character positions: ‘pos1:pos2’ / ‘all’ / ‘none’.
‘no’ / ‘yes’, attaches a spin control to the text box.
‘right’ / ‘left’, with respect to the text (GTK always ‘right’).
‘yes’ / ‘no’, updates value of control when spin buttons used. When ‘no’, “spin_cb” must adjust the value.
Increment value, defaults to 1.
Maximum spin value, defaults to 100.
Minimum spin value, defaults to 1.
Current value of spin, defaults to 1.
‘no’ / ‘yes’, automatically wraps spin at ends of range, when set.
In multi-line mode, controls number of spaces used for a tab, defaults to 8.
Tooltip string.
Retrieves or sets the text.
Retrieves or sets the text, applying MASK when setting.
The minimum number of visible columns, defaults to 5.
The minimum number of visible lines, when dropdown=no.
Forces a word wrap of lines longer than width of control. Values ‘no’ / ‘yes’, when multiline=yes.
Public Class Methods
Source
# File lib/wrapped/text.rb, line 40 def initialize @handle = IupLib.IupText(nil) # run any provided block on instance, to set up further attributes yield self if block_given? end
Creates a new instance. If a block is given, the new instance is yielded to it.
Callbacks
Attributes
Callback called when the text is edited, but before its value is actually changed. Callback must respond to call and takes a 2-argument callback: (character, new_value)
-
character- the character typed -
new_value- the new text value
Return Iup::IGNORE to ignore the new_value and allow the character to be added to the text.
Callback called when the caret/cursor position is changed. Callback must respond to call and takes a callback which accepts 3 arguments (line, column, position) of caret
-
line- line number (1-indexed) -
column- column number (1-indexed) -
position- character position (0-indexed)
Callback called when the mouse is moved. Callback must respond to call and takes 3 arguments: (x, y, state)
-
x- x position of mouse -
y- y position of mouse -
state- status of mouse buttons and certain keyboard keys at the moment the event was generated.
Callback called when a spin button is pressed. Valid only when SPIN=YES. Callback must respond to call and take a 1-argument callback: (value)
-
value- the value of spin control.
Sets callback called after the value was interactively changed by the user. Callback must respond to call and take no arguments.