This is a multi-line editbox or input box with scrollbars allowing you to
enter data. Some interesting notes regarding the on_enter_key and on_tab_key events:
- The enter key inserts a line feed into the editbox.
- The tab key (on_tab_key event) moves the
focus to the next or previous object.
- The ctrl-tab (on_tab_key event with
control key pressed) inserts spaces into the editbox.
Based on the Lframe class so scrollbars are
supported. Here are the attributes that are created specifically for the
editbox object:
The speed of the blinking cursor is determined by the constant
CURSOR_BLINK_TIME and defaults to 600 millisecs.
auto_select,
auto_select=,
char_count,
clear,
cursor_blinking,
cursor_position,
cursor_position=,
default_bg,
default_border,
default_mouse_cursor,
get_char,
get_line,
highlighted?,
hscroll,
hscroll_position=,
include_objects,
inherit_color_from_parent?,
inherits_attribute?,
insert_mode,
insert_mode=,
ipadx,
ipady,
is_byte_a_word_boundary?,
line_count,
max_line,
max_size,
max_size=,
nearest,
on_backspace_key,
on_before_update,
on_change,
on_copy,
on_cut,
on_delete_key,
on_down_key,
on_end_key,
on_enter_key,
on_exit,
on_home_key,
on_insert_key,
on_key_press,
on_key_release,
on_left_key,
on_mouse_ldn,
on_mouse_lup,
on_mouse_move,
on_next_word,
on_pagedown_key,
on_pageup_key,
on_paste,
on_prev_word,
on_resize,
on_right_key,
on_scroll,
on_tab_key,
on_up_key,
paint_focus,
paint_focus?,
paint_focus_remove,
paint_normal,
pixel_height,
pixel_height_total,
pixel_width,
pixel_width_total,
prepare,
scroll_distance,
scroll_distance_alignment,
select_text,
set_focus,
skip_object_theme,
tab_size,
valid_attribute?,
value,
value=,
visible_line_count,
vscroll_position=,
word_wrap,
word_wrap=,
Supports several attributes specific to the editbox.
Textbox and editbox objects don’t inherit the background color from
the parent object.
Returns false because editbox objects don’t inherit color from parent
objects.
Returns true because the editbox does not pull attributes from the :object
attribute of any style.
The default is 3. Pressing the ctrl-tab key (on_tab_key event) inserts spaces into the
editbox such that the current cursor position is moved to this boundary
point. For example, when at cursor position 1, pressing the tab key inserts
two spaces.
The default is 3 so the text does not hug the left and right border.
The default is 2 so the text does not hug the top and bottom border.
Returns true. Leditbox object get a focus.
Needed since this is based on the Lframe class
and the Lframe class does not paint a focus by
default.
If word wrapping (:word_wrap attribute)
is on, returns false because the horizontal scrollbar is disabled when word
wrapping is on.
Returns the current state of word wrapping. True, false or nil. The default
is false, word wrapping is off by default.
Turn word wrapping on or off.
- new_value - true turns word wrapping on, false turns it off, nil resets
word wrapping back to the default setting.
Positions the cursor after the object is prepared.
Defines several instance variables and creates a timer for blinking the
cursor.
Returns the self[:value] attribute as a string. The :value attribute is
stored as an Array of strings for performance
reasons.
Clears the selection or highlight, resets the cursor position, and converts
new_value to an Array.
Returns the current state of insert_mode. The default is true.
Sets insert mode on or off.
- new_value - true to turn on insert mode, false to turn off insert mode, nil
to return to the default insert mode.
The default is false. When true, the entire content of the editbox is
highlighted every time the cursor enters the editbox.
Calls the Lobject version of clear() rather than
Lframe version of clear().
Sets the :auto_select attribute on or
off.
- new_value - true to select or highlight the entire content of the editbox
every time the cursor enters the editbox, false to not select the content
of the editbox when the cursor enter the editbox, or nil to return to the
default setting.
Returns the maximum number of characters that can be entered into this
editbox. The default is unlimited (limited by memory and/or the size of a
Ruby String).
Sets the maximum number of characters that can be entered into this
editbox.
- new_value - the maximum number of characters to allow in this editbox
object.
Selects or highlights the text between start and end. Use (0,0, -1,-1) to
select all text. Use (0,0, 0,0) to clear the selection.
- start_line - the line number to start highlighting text at.
- start_col - the column number within line_number to start highlighting text
at.
- end_line - the line number to stop highlighting text at.
- end_col - the column number within line_number to stop highlighting text
at.
Returns the character index (as a Leditbox_position) closest to lx, ly (the
screen relative mouse position, levent[:x], levent[:y]).
- lx - the screen relative x pixel position of the mouse (levent[:x}).
- ly - the screen relative y pixel position of the mouse (levent[:x}).
Returns the current position of the cursor (as Leditbox_position) in
self[:value].
Sets the position of the cursor to new_pos. Calls cursor_position_set(). If
the text at the new cursor position is not visible, the text is
automatically scrolled so the cursor is visible.
- new_pos - is either an array or [line, col] or a Leditbox_position object.
If word wrapping is turned on then rewrap the text in the editbox.
This is a little different than the normal on_change event for performance reasons.
This occurs after the change has been applied to the object, thus,
editbox[:value] equals levent[:value] and is the content of the editbox as
an array or strings (or lines) and editbox.value is the content of the
editbox as a string. Here are some distinctions on the content of levent:
- levent[:ievent] is the event that triggered this event such as :on_cut, :on_paste, :on_key_press, etc.
- levent[:keycode] contains the character just inserted or contains the
action being taken to modify the editbox such as the delete key or
backspace key.
- levent[:value] is the same as editbox[:value] and is the content of the
editbox as an array of strings (lines).
Automatically un-selects or de-highlighted any highlighted text.
The editbox needs to use dup rather than clone to make a copy of the :value
attribute because the :value attribute is an Array. The copy of the :value attribute is used by
the :undo event.
Inserts the content of the clipboard into the editbox at cursor_position. If there is selected or
highlighted text, triggers the on_cut
event to remove the highlighted text. Also triggers the on_change event just after the new text is
pasted into the editbox.
- levent[:value] contains the text that is pasted into the editbox.
Cuts the selected or highlighted text from the editbox and places it in the
clipboard. Triggers the on_change event
just after the highlighted text is cut from the editbox.
- levent[:value] contains the highlighted portion of the text to be cut out
of the editbox.
Copies the highlighted text from the editbox to the clipboard.
- levent[:value] contains the highlighted portion of the text.
The tab key and shift tab moves the focus to the next or previous object.
The ctrl tab key is converted to spaces and inserted into the editbox.
Spaces are inserted spaces into the editbox such that the current cursor
position is moved to the tab_size
boundary. For example, when at cursor position 1, pressing the tab key
inserts two spaces. Use ctrl-tab to move to the next object and
ctrl-shift-tab to move to the previous object.
Eliminates any selected or highlighted text and the character before the
cursor.
If any text is selected or highlighted, it is removed unless the Alt, Ctrl,
or Shift keys are pressed with the delete key. If there is no selected or
highlighted text the character after the cursor is deleted as long as the
Alt, Ctrl, or Shift keys are not pressed.
Inserts a line feed/carriage return in the editbox. Also removes any
selected or highlighted text from the editbox.
Toggles insert mode on and off.
Ctrl-w toggles word wrap on and off.
Inserts the character associated with the on_key_press event into the editbox
and triggers the on_change event. Also
removes any selected or highlighted text from the editbox.
Ctrl-home key move to the first line in the editbox. Otherwise, the first
home key press moves the cursor to the first non-space character in the
line and the second home key press moves the cursor to the first character
on the line.
Ctrl-end key move to the last line in the editbox. Otherwise, moves the
cursor to the last character on the current line.
This is called by on_next_word() and on_prev_word() to determine the start of
the next or previous word. Returns false if byte matches any of these
characters:
‘0,1,2,3,4,5,6,7,8,9,0,_,:,?,@,A,B,…,Y,Z,_,`,a,b,…,y,z’
except ’,’ and ’…’ which represents rest of
the alphabet.
Moves the cursor to the next word in the editbox. Holding the shift key
will select or highlight to the next word. Called when the user does a
ctrl-right_key to move to the next word. The method is_byte_a_word_boundary?() is used to
determine what the first character of a word is.
Moves the cursor to the previous word in the editbox. Holding the shift key
will highlight to the previous word. Called when the user does a
ctrl-left_key to move to the previous word. The method is_byte_a_word_boundary?() is used to
determine what the first character of a word is.
The moves the cursor up one line. Holding the shift key highlights
characters.
The moves the cursor down one line. Holding the shift key highlights
characters.
The moves the cursor one character to the left. Holding the ctrl key
triggers the on_prev_word event.
Holding the shift key highlights the previous character.
The moves the cursor one character to the right. Holding the ctrl key
trigger the on_next_word event. Holding
the shift key will highlight the next character.
Repositions the cursor and clears any selected or highlighted text. Also
prepares for dragging the highlight as the mouse is moved.
Clears any preparation for dragging the highlight as the mouse is moved.
Sets the current cursor position to character nearest the mouse.
Drags or expands the highlight when left mouse button is pressed.
Paints the content of the editbox and takes into consideration any
highlighted or selected text, font, and colors.
The scrollbars use this value for determining the alignment when dragging
the scroller button. The default is the height of a single line of text for
vertical scrollbars and super for horizontal scrollbars. It keeps the top
line fully visible at all times.
The scrollbars use this value for determining the scrolling distance when
pushing one of the buttons in the scrollbar. The default is the height of a
single line of text for vertical scrollbars and super for horizontal
scrollbars.
Sets the horizontal scroll position. This scrolls the text in the editbox.
The editbox automatically uses this to scroll horizontally when you type in
more characters than you can see. This is used to make sure you can always
see what you are typing.
Sets the vertical scroll position. This scrolls the text in the editbox.
The editbox automatically uses this to scroll vertically when you type in
more characters that you can see. This is used to make sure you can always
see what you are typing.
Triggered whenever the scroller is moved. Repaints the editbox to reflect
the new position when needed.
Returns true if the character at line, col is highlighted.
Returns the number of characters in the editbox. Includes the line feed
character at the end of each line.
This returns the number of lines of text visible in the editbox.
Returns the number of lines in the editbox.
Returns the line number of the last line in the editbox. 0 relative.
Returns the text or string at line where line is the row you want. If line
== nil, the line at the current cursor position is returned.
Returns the character at line, col. If line == nil or col == nil, then the
current cursor position line and col are used.
Draws the cursor (focus indicator), removes the cursor, and causes the
cursor to blink. Leditbox::CURSOR_BLINK_TIME determines the rate of
blinking.
Calls cursor_blinking() to draw the
cursor, remove the cursor, and blink the cursor.
Calls cursor_blinking() to draw the
cursor, remove the cursor, and blink the cursor.
Returns the pixel width of the text in the object. This should take into
consideration the font, size, and style of the object and it’s
parents. This is used to calculate width of the object when needed.
Returns the pixel height of the text in the object. This should take into
consideration the font, size, and style of the object and it’s
parents. This is used to calculate height of the object when needed. The
default is to return the greater of the height of the :value attribute or
height of two lines of text.
Returns the total pixel width needed by the text currently in the editbox.
Returns the total pixel height needed by the text currently in the editbox.
Thank you for taking the time to visit this web page. I trust you found the information contained in this page useful.
Please email any questions, concerns, or issues with this web site to webmaster@sevasoftware.com.
Please remember Seva Software when your company would benefit from an experienced database architect and software engineer.