Class: Gosu::TextInput
- Inherits:
-
Object
- Object
- Gosu::TextInput
- Defined in:
- rdoc/gosu.rb
Overview
A TextInput is an invisible object that handles input using the operating system’s input manager.
At its most basic, you only need to set Window#text_input to an instance of this class. The TextInput will then handle all keyboard input until Window#text_input is set to ‘nil`. Any text the user has typed is available through #text.
This class is purely back-end and does not come with a GUI; drawing the input field is up to you, the programmer. The best way to do that is left completely open. TextInput only aims to provide a foundation for you to build your own GUI.
Instance Attribute Summary collapse
-
#caret_pos ⇒ Integer
The position of the editing caret.
-
#selection_start ⇒ Integer
The starting position of the currently selected text.
-
#text ⇒ String
The text that the user has typed.
Instance Method Summary collapse
-
#delete_backward ⇒ Object
Deletes the current selection, if any, or the previous character.
-
#delete_forward ⇒ Object
Deletes the current selection, if any, or the next character.
-
#filter ⇒ String
This method is an overridable filter that is applied to all newly entered text.
-
#insert_text(str) ⇒ Object
Replaces the current selection (if any) and inserts the given string at the current caret position.
Instance Attribute Details
#caret_pos ⇒ Integer
Returns the position of the editing caret.
726 727 728 |
# File 'rdoc/gosu.rb', line 726 def caret_pos @caret_pos end |
#selection_start ⇒ Integer
Returns the starting position of the currently selected text.
730 731 732 |
# File 'rdoc/gosu.rb', line 730 def selection_start @selection_start end |
#text ⇒ String
Returns the text that the user has typed.
722 723 724 |
# File 'rdoc/gosu.rb', line 722 def text @text end |
Instance Method Details
#delete_backward ⇒ Object
Deletes the current selection, if any, or the previous character.
760 |
# File 'rdoc/gosu.rb', line 760 def delete_backward; end |
#delete_forward ⇒ Object
Deletes the current selection, if any, or the next character.
756 |
# File 'rdoc/gosu.rb', line 756 def delete_forward; end |
#filter ⇒ String
This method is an overridable filter that is applied to all newly entered text. This allows for restricting input characters or format, automatic macro or abbreviation expansion and so on.
The return value of this method will be inserted at the current caret position.
The default implementation returns its argument unchanged.
747 |
# File 'rdoc/gosu.rb', line 747 def filter; end |
#insert_text(str) ⇒ Object
Replaces the current selection (if any) and inserts the given string at the current caret position. The filter method will not be applied before appending the string.
752 |
# File 'rdoc/gosu.rb', line 752 def insert_text(str); end |