Class: UI::UserInput
- Inherits:
-
Text
- Object
- LiteRGSS::Disposable
- LiteRGSS::Drawable
- LiteRGSS::Text
- Text
- UI::UserInput
- Defined in:
- scripts/01450 Systems/00000 General/00100 UI Generics/00700 UserInput.rb
Overview
Class responsive of dealing with Keyboard user input (for search or other stuff like that).
This is a Text that takes the same parameters as regular texts but has a `init` method allowing to tell how much characters are allowed, what kind of character to use for empty chars and give the handler
Example
```ruby
@search = add_text(x, y, width, height, 'default_text', type: UI::UserInput)
@search.init(25, '', on_new_char: method(:add_char), on_remove_char: method(:del_char))
# ...
def add_char(complete_string, new_char)
# ...
def del_char(complete_string, removed_char)
```
Constant Summary collapse
- CTRL_V =
Code used to detect CTRL+V
"\u0016"
- BACK =
Code used to detect backspace
"\b"
Instance Attribute Summary
Attributes inherited from LiteRGSS::Text
#__index__, #align, #bold, #draw_shadow, #fill_color, #height, #italic, #nchar_draw, #opacity, #outline_color, #outline_thickness, #real_width, #size, #text, #viewport, #visible, #width, #x, #y, #z
Instance Method Summary collapse
-
#init(max_size, empty_char = '_', on_new_char: nil, on_remove_char: nil)
Init the user input.
-
#update
Update the user input.
Methods inherited from Text
#simple_mouse_in?, #translate_mouse_coords
Methods inherited from LiteRGSS::Text
#load_color, #multiline_text=, new, #set_position, #text_width
Methods inherited from LiteRGSS::Disposable
Instance Method Details
#init(max_size, empty_char = '_', on_new_char: nil, on_remove_char: nil)
Init the user input
26 27 28 29 30 31 32 33 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00700 UserInput.rb', line 26 def init(max_size, empty_char = '_', on_new_char: nil, on_remove_char: nil) @current_text = '' @max_size = max_size.abs @empty_char = empty_char @on_new_char = on_new_char @on_remove_char = on_remove_char load_text(text) end |