This mod adds components to get text input from player. It simply acts as a library for other mods that need such a tool.
You can select text by holding Shift and moving caret or simply using your mouse.
Here are all the functions supported when entering text:
| Numpad Enter | add new line |
| Enter | validate operation |
| Esc | cancel operation |
| Ctrl + C | copy text to clipboard |
| Ctrl + V | paste text from clipboard |
| Ctrl + X | cut selected text to clipboard |
| Up Arrow | move caret to the line above |
| Down Arrow | move caret to the line below |
| Left Arrow | move caret by 1 character to the left |
| Ctrl + Left Arrow | move caret by 1 word to the left |
| Right Arrow | move caret by 1 character to the right |
| Ctrl + Right Arrow | move caret by 1 word to the right |
| Home | move caret to beginning of line |
| Ctrl + Home | move caret to beginning of text |
| End | move caret to end of line |
| Ctrl + End | move caret to end of text |
| Page Up | move caret to previous page |
| Page Down | move caret to next page |
| Backspace | erase previous character |
| Ctrl + Backspace | erase previous word |
| Del | erase next character |
| Ctrl + Del | erase next word |
If you're a mod maker, read what follows!
To declare QuickKeyboardInput as a dependency, first you need , then just add the following lines to your mod.txt:
"simple_dependencies" : {
"QuickKeyboardInput": "http://pd2mods.z77.fr/update/QuickKeyboardInput.zip"
},
This short piece of code...
function qki_callback_ok(text)
log("user typed: " .. tostring(text))
end
local title = 'Title'
local message = 'Message'
local params = {
default_value = 'default',
changed_callback = qki_callback_ok
}
local show_immediately = true
QuickKeyboardInput:new(title, message, params, show_immediately)
...will produce this result:
You can easily render any panel:text() object editable by using class QuickKeyboardInputHusk.
First, you create event callbacks:
function ThingYouArePatching:accept_callback(text) self.qki = nil -- do something with variable text end function ThingYouArePatching:cancel_callback() self.qki = nil end
Then you initialize it where needed with current workspace, text object and callbacks:
self.qki = QuickKeyboardInputHusk:new(workspace, text_object, {
changed_callback = callback(self, self, 'accept_callback'),
cancel_callback = callback(self, self, 'cancel_callback')
})
To know if user is currently editing something, you just check on self.qki.
For a real use case, this is implemented in to manage text typed to filter items; look for self.si_qki in its files.
| cancel_callback | function | called if aborted |
| changed_callback | function | called on success, typed text is found in first parameter |
| changing_callback | function | called on each change, typed text is found in first parameter |
| default_value | string | ... |
| set_selection_from | number | define position of caret |
| set_selection_to | number | preselect text |
| halign | string | horizontal alignment of typed text, expected values are left, center and right |
| valign | string | vertical alignment of typed text, expected values are top, center and bottom |
| max_length | number | maximum number of characters |
| max_size | number | maximum number of bytes |
| multiline | boolean | if false then typing numpad enter won't have any effect |
| word_wrap | boolean | ... |
| w | number | set a specific width on dialog box |
| forced_h | number | force a specific height on dialog box |
| is_title_outside | boolean | ... |
| max_lines | number | limit autoresize, if you define a limit of 5 and type 10 lines, a scrollbar will appear |
| no_mouse | boolean | hide mouse cursor |
| no_corners | boolean | remove dialog corners, only effective for modal use |
| font | string | ... |
| font_size | number | ... |
| title_font | string | ... |
| title_font_size | number | ... |
| text_blend_mode | string | ... |
| text_formating_color | userdata | ... |
| text_formating_color_table | table | ... |
| use_text_formating | boolean | ... |
| not_editable | boolean | prevent text modifications but not selection |
| scroll_by_x_lines | number | specify by how many lines to scroll when using mouse wheel, default value is 3 |