better text entry - bugfixes

This commit is contained in:
kepler155c@gmail.com 2019-03-29 15:47:01 -04:00
parent c1baf107c1
commit 19159730a4
4 changed files with 13 additions and 12 deletions

View File

@ -327,24 +327,26 @@ local mappings = {
[ 'end' ] = Entry.moveEnd,
[ 'control-e' ] = Entry.moveEnd,
[ 'mouse_click' ] = Entry.moveTo,
[ 'backspace' ] = Entry.backspace,
[ 'control-right' ] = Entry.moveWordRight,
[ 'alt-f' ] = Entry.moveWordRight,
[ 'control-left' ] = Entry.moveWordLeft,
[ 'alt-b' ] = Entry.moveWordLeft,
[ 'mouse_doubleclick' ] = Entry.markWord,
[ 'backspace' ] = Entry.backspace,
[ 'delete' ] = Entry.delete,
[ 'char' ] = Entry.insertChar,
[ 'mouse_rightclick' ] = Entry.clearLine,
[ 'control-c' ] = Entry.copy,
[ 'control-u' ] = Entry.cutFromStart,
[ 'control-k' ] = Entry.cutToEnd,
--[ 'control-d' ] = Entry.cutNextWord,
[ 'control-w' ] = Entry.cutPrevWord,
[ 'char' ] = Entry.insertChar,
[ 'control-c' ] = Entry.copy,
--[ 'control-d' ] = Entry.cutNextWord,
[ 'control-x' ] = Entry.cut,
[ 'paste' ] = Entry.paste,
[ 'control-y' ] = Entry.paste,
[ 'mouse_rightclick' ] = Entry.clearLine,
[ 'mouse_doubleclick' ] = Entry.markWord,
[ 'shift-left' ] = Entry.markLeft,
[ 'shift-right' ] = Entry.markRight,
[ 'mouse_down' ] = Entry.markAnchor,

View File

@ -261,7 +261,7 @@ function Manager:click(target, code, button, x, y)
clickEvent.button = button
clickEvent.type = code
clickEvent.key = code
clickEvent.ie = { code = code, x = x, y = y }
clickEvent.ie = { code = code, x = clickEvent.x, y = clickEvent.y }
if clickEvent.element.focus then
target:setFocus(clickEvent.element)

View File

@ -35,13 +35,13 @@ end
function UI.TextEntry:setValue(value)
self.value = value
self.entry:unmark()
self.entry.value = value
self.entry.value = tostring(value)
self.entry:updateScroll()
end
function UI.TextEntry:setPosition(pos)
self.entry.pos = pos
self.entry.value = self.value
self.entry.value = tostring(self.value)
self.entry:updateScroll()
end
@ -86,6 +86,7 @@ end
function UI.TextEntry:reset()
self.entry:reset()
self.value = ''
self:draw()
self:updateCursor()
end
@ -105,7 +106,7 @@ end
function UI.TextEntry:eventHandler(event)
local text = self.value
self.entry.value = text
self.entry.value = tostring(text)
if event.ie and self.entry:process(event.ie) then
if self.entry.textChanged then
self.value = self.entry.value

View File

@ -662,8 +662,6 @@ local function shellRead(history)
end
end
--local _, cy = term.getCursorPos()
--term.setCursorPos( w + 1, cy )
print()
term.setCursorBlink( false )
return entry.value