Class: UI::UserInput

Inherits:
Text show all
Defined in:
docs/01450_Systems_00000_General_00100_UI_Generics.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

''
BACK =

Code used to detect backspace

''

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

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

#dispose, #disposed?

Instance Method Details

#init(max_size, empty_char = '_', on_new_char: nil, on_remove_char: nil)

Init the user input

Parameters:

  • max_size (Integer)

    maximum size of the user input

  • empty_char (String) (defaults to: '_')

    char used to replace all the remaining empty char

  • on_new_char (#call, nil) (defaults to: nil)

    called when a char is added

  • on_remove_char (#call, nil) (defaults to: nil)

    called when a char is removed



859
860
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 859

def init(max_size, empty_char = '_', on_new_char: nil, on_remove_char: nil)
end

#update

Update the user input



862
863
# File 'docs/01450_Systems_00000_General_00100_UI_Generics.rb', line 862

def update
end