mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-11-26 05:14:21 +00:00
new util library function and textinput fixes
added util library function: TableHasValue(table, value) fixed ability to bypass textinput restrictions with clipboard functionality fixed textinput:GetText appending an extra newline to then end of the text string
This commit is contained in:
parent
bc768d7165
commit
8431f323b1
@ -4,11 +4,13 @@ Version 0.9.6.4 - Alpha (Release Date TBD)
|
|||||||
[ADDED] a new tooltip method: SetOffsetX(xoffset)
|
[ADDED] a new tooltip method: SetOffsetX(xoffset)
|
||||||
[ADDED] a new tooltip method: SetOffsetY(yoffset)
|
[ADDED] a new tooltip method: SetOffsetY(yoffset)
|
||||||
[ADDED] a new tooltip method: GetText()
|
[ADDED] a new tooltip method: GetText()
|
||||||
|
[ADDED] a new library function: TableHasValue(table, value)
|
||||||
[ADDED] basic clipboard support for the textinput object (0.9.0 only)
|
[ADDED] basic clipboard support for the textinput object (0.9.0 only)
|
||||||
|
|
||||||
[FIXED] error when pressing a function key while a textinput was focused
|
[FIXED] error when pressing a function key while a textinput was focused
|
||||||
[FIXED] the tooltip object not setting the state of its text object
|
[FIXED] the tooltip object not setting the state of its text object
|
||||||
[FIXED] the text object not being set to the correct width in certain situations
|
[FIXED] the text object not being set to the correct width in certain situations
|
||||||
|
[FIXED] textinput:GetText appending an extra newline to then end of the text string
|
||||||
|
|
||||||
[CHANGED] cleaned up the tooltip object
|
[CHANGED] cleaned up the tooltip object
|
||||||
|
|
||||||
|
@ -475,7 +475,39 @@ function newobject:keypressed(key, unicode)
|
|||||||
end
|
end
|
||||||
elseif key == "v" and version == "0.9.0" and editable then
|
elseif key == "v" and version == "0.9.0" and editable then
|
||||||
local text = love.system.getClipboardText()
|
local text = love.system.getClipboardText()
|
||||||
|
local usable = self.usable
|
||||||
|
local unusable = self.unusable
|
||||||
|
local limit = self.limit
|
||||||
local onpaste = self.OnPaste
|
local onpaste = self.OnPaste
|
||||||
|
if limit > 0 then
|
||||||
|
local curtext = self:GetText()
|
||||||
|
local curlength = curtext:len()
|
||||||
|
for i=1, #curtext do
|
||||||
|
print(i, curtext:sub(i, i):byte())
|
||||||
|
end
|
||||||
|
if curlength == limit then
|
||||||
|
return
|
||||||
|
else
|
||||||
|
local inputlimit = limit - curlength
|
||||||
|
if text:len() > inputlimit then
|
||||||
|
text = text:sub(1, inputlimit)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local charcheck = function(a)
|
||||||
|
if #usable > 0 then
|
||||||
|
if not loveframes.util.TableHasValue(usable, a) then
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
elseif #unusable > 0 then
|
||||||
|
if loveframes.util.TableHasValue(unusable, a) then
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #usable > 0 or #unusable > 0 then
|
||||||
|
text = text:gsub(".", charcheck)
|
||||||
|
end
|
||||||
if alltextselected then
|
if alltextselected then
|
||||||
self:SetText(text)
|
self:SetText(text)
|
||||||
else
|
else
|
||||||
@ -1252,13 +1284,8 @@ function newobject:SetText(text)
|
|||||||
local tabreplacement = self.tabreplacement
|
local tabreplacement = self.tabreplacement
|
||||||
local multiline = self.multiline
|
local multiline = self.multiline
|
||||||
|
|
||||||
-- make sure the text is a string
|
|
||||||
text = tostring(text)
|
text = tostring(text)
|
||||||
|
|
||||||
-- replace any tabs character with spaces
|
|
||||||
text = text:gsub(string.char(9), tabreplacement)
|
text = text:gsub(string.char(9), tabreplacement)
|
||||||
|
|
||||||
-- remove any carriage returns
|
|
||||||
text = text:gsub(string.char(13), "")
|
text = text:gsub(string.char(13), "")
|
||||||
|
|
||||||
if multiline then
|
if multiline then
|
||||||
@ -1290,7 +1317,10 @@ function newobject:GetText()
|
|||||||
|
|
||||||
if multiline then
|
if multiline then
|
||||||
for k, v in ipairs(lines) do
|
for k, v in ipairs(lines) do
|
||||||
text = text .. v .. "\n"
|
text = text .. v
|
||||||
|
if k ~= #lines then
|
||||||
|
text = text .. "\n"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
text = lines[1]
|
text = lines[1]
|
||||||
|
23
util.lua
23
util.lua
@ -246,22 +246,35 @@ function loveframes.util.RemoveAll()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[---------------------------------------------------------
|
||||||
|
- func: loveframes.util.TableHasValue(table, value)
|
||||||
|
- desc: checks to see if a table has a specific value
|
||||||
|
--]]---------------------------------------------------------
|
||||||
|
function loveframes.util.TableHasValue(table, value)
|
||||||
|
|
||||||
|
for k, v in pairs(table) do
|
||||||
|
if v == value then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
- func: loveframes.util.TableHasKey(table, key)
|
- func: loveframes.util.TableHasKey(table, key)
|
||||||
- desc: checks to see if a table has a specific key
|
- desc: checks to see if a table has a specific key
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function loveframes.util.TableHasKey(table, key)
|
function loveframes.util.TableHasKey(table, key)
|
||||||
|
|
||||||
local haskey = false
|
|
||||||
|
|
||||||
for k, v in pairs(table) do
|
for k, v in pairs(table) do
|
||||||
if k == key then
|
if k == key then
|
||||||
haskey = true
|
return true
|
||||||
break
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return haskey
|
return false
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user