It looks like you're new here. If you want to get involved, click one of these buttons!
local function append(tf, text) tf:setText(tf:getText() .. text) end local UTF = utf8.char function TextBox:input(real, actual) if actual == KeyCode.BACKSPACE then local str = self.label:getText() self.label:setText(str:sub(1,str:len()-1)) else if real == 1025 then -- "ё" special case local char = "" if self.isShiftPressed then char = UTF(1025) else char = UTF(1105) end append(self.label, char) -- Latin & Cyrillic alphabet codes elseif (real >= 65 and real <= 90) or (real >= 1040 and real <= 1071) then local char = "" if self.isShiftPressed then char = UTF(real) -- upper case else char = UTF(real+32) -- lower case end append(self.label, char) elseif real <= 9600 then -- to prevent appending most of functional code like F1,F2,...,HOME,END,TAB etc. append(self.label, UTF(real)) end end self:updatePos() -- update cursor position end -- function TextBox:keyDown(e) if self.line:isVisible() then --print(e.keyCode, e.realCode) if e.keyCode == KeyCode.SHIFT then self.isShiftPressed = true elseif e.keyCode == KeyCode.CTRL then self.isCtrlPressed = true end self.activeKey = e.keyCode self.activeRKey = e.realCode self.counter = 0 self:input(self.activeRKey,self.activeKey) self.holdTimer:reset() self.holdTimer:start() end end -- function TextBox:keyUp(e) if self.line:isVisible() then if e.keyCode == self.activeKey then self.activeKey = nil self.holdTimer:stop() elseif e.keyCode == KeyCode.SHIFT then self.isShiftPressed = false elseif e.keyCode == KeyCode.CTRL then self.isCtrlPressed = false end if self.activeRKey == e.realCode then self.activeRKey = nil self.holdTimer:stop() end end end |
Comments
A couple questions about "TAB" symbol.
1. Why it does not stack? (you can see it on a gif, it works like normal space symbol)
2. Why does the text think it is a regular space?