Class: Tuile::Component::BigDecimalField::Field
- Inherits:
-
TextField
- Object
- Component
- AbstractStringField
- TextField
- Tuile::Component::BigDecimalField::Field
- Defined in:
- lib/tuile/component/big_decimal_field.rb,
sig/tuile.rbs
Overview
The face: a TextField that admits only the buffers a decimal can be typed through, however the characters arrive.
Constant Summary collapse
- TYPEABLE =
Buffers reachable by typing a decimal: an optional leading
-and digits with at most one.. Looser than NUMERIC on purpose —"","-"and"1."are members, or the values past them could not be typed at all. /\A-?\d*(?:\.\d*)?\z/
Instance Attribute Summary
Attributes inherited from TextField
#left_column, #max_text_length, #on_enter, #on_key_down, #on_key_up
Attributes inherited from AbstractStringField
#caret, #on_change, #on_escape, #text
Attributes included from HasValue
Attributes included from HasValidation
Instance Method Summary collapse
-
#insert_text(str) ⇒ Boolean
Accepts the insertion only if the whole resulting buffer is still typeable, so a pasted
"$19.99"is dropped rather than sieved into"19.99"— a price the user never copied.
Methods inherited from TextField
#adjust_left_column, #column_at, #cursor_position, #display_text, #handle_caret_mutated, #handle_mouse_down?, #handle_text_input_key?, #handle_text_mutated, #handle_width_changed, #index_at, #initialize, #insert, #inspect_details, #placeholder, #placeholder=, #placeholder_row, #preprocess_paste, #repaint, #show_placeholder?, #snap_to_glyph_start, #text_columns, #visible_text
Methods included from HasPlaceholder
#inspect_details, #placeholder, #placeholder=
Methods inherited from AbstractStringField
#clear, #cluster_boundary_after, #cluster_boundary_before, #columns_of, #default_bg_color, #default_on_escape, #delete_at_caret, #delete_back_to, #delete_before_caret, #empty?, #empty_value, #error_bg_color, #error_ink?, #error_message, #error_message=, #focusable?, #handle_caret_mutated, #handle_key?, #handle_paste, #handle_text_input_key?, #handle_text_mutated, #initialize, #inspect_details, #preprocess_paste, #preprocess_text, #snap_to_cluster, #tab_stop?, #value, #value=, #word_left, #word_right
Methods included from HasValue
#clear, #empty?, #empty_value, #error_bg_color, #error_ink?, #error_message, #error_message=, #focusable?, #inspect_details, #value, #value=
Methods included from HasValidation
#error_bg_color, #error_ink?, #error_message, #error_message=, #inspect_details
Constructor Details
This class inherits a constructor from Tuile::Component::TextField
Instance Method Details
#insert_text(str) ⇒ Boolean
Accepts the insertion only if the whole resulting buffer is still
typeable, so a pasted "$19.99" is dropped rather than sieved into
"19.99" — a price the user never copied.
@param str
@return — true if the text changed.
91 92 93 94 95 |
# File 'lib/tuile/component/big_decimal_field.rb', line 91 def insert_text(str) return false unless TYPEABLE.match?(@text.dup.insert(@caret, str)) super end |