Edit:hscroll(kind)method
Scrolls the Edit text horizontally.
Parameters
kind
A string value, representing the the kind of horizontal scrolling :
- "left", "right", "lineleft", "lineright", "pageleft", "pageright"
"left": scrolls the text to the upper left."reight": scrolls the text to the lower right."lineleft": scrolls the text left by one unit."lineright": scrolls the text right by one unit."pageleft": scrolls the text left by the width of the Edit."pagedown": scrolls the text right by the width of the Edit.
Return value
This function returns no value.Example
--! luart-extensions
import ui
-- create a simple Window
local win = ui.Window("Edit.scroll sample", "fixed", 640, 480)
local cb = ui.Combobox(win, {"Scroll to the left", "Scroll to the right", "Scroll one unit left", "Scroll one unit right", "Scroll one page left", "Scroll one page right"})
local edit = ui.Edit(win, "", 0, 0, 480, 480)
cb:center()
cb.width = 140
cb.x = math.floor(edit.width+(640-edit.width-cb.width)/2)
edit:load(arg[0])
edit.text = edit.text..edit.text
local values = {
["Scroll to the left"] = "left",
["Scroll to the right"] = "right",
["Scroll one unit left"] = "lineleft",
["Scroll one unit right"] = "lineright",
["Scroll one page left"] = "pageleft",
["Scroll one page right"] = "pageright"
}
function cb:onSelect()
edit:hscroll(values[cb.text])
end
await win:showasync()