Edit:onSelect(start, end) event


Event fired when the user has made a selection in the Edit Widget.

Parameters

start

The character position at the start of the selection.

end

The character position at the end of the selection.

  • Selection and caret position are expressed in characters : the cursor in position 1 is just before the first character.
  • Selection includes everything if it starts at position 1 and ends at position 0.
  • The selection is empty if its end and start are the same.

Return value

The event returns no value.

Example

local ui = require "ui" -- create a simple window local win = ui.Window("Edit:onSelect() sample", "fixed", 340, 230) local label = ui.Label(win, "Enter text : ", 10, 10) local edit = ui.Edit(win, "", label.x + label.width + 8, label.y) -- set edit.properties edit.font = "Times New Roman" edit.fontsize = 10 edit.wordwrap = true edit.text = [[Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.]] -- update status bar with the current selection function edit:onSelect(s, e) win:status("Selection start : "..s, "Selection end :"..e) end -- update status bar edit:onSelect(1,1) win:show() -- update user interface repeat ui.update() until not win.visible