mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-11-26 05:14:21 +00:00
Merge pull request #92 from sharpobject/master
Add cut for text input, use cmd instead of ctrl on macs
This commit is contained in:
commit
e131ed8628
@ -514,7 +514,7 @@ function newobject:SelectRow(row, ctrl)
|
||||
end
|
||||
end
|
||||
elseif v ~= row then
|
||||
if (not multiselect and ctrl) or (not multiselect and not ctrl) or (multiselect and not ctrl) then
|
||||
if not (multiselect and ctrl) then
|
||||
v.selected = false
|
||||
end
|
||||
end
|
||||
|
@ -118,7 +118,7 @@ function newobject:mousepressed(x, y, button)
|
||||
end
|
||||
local parent1 = self:GetParent()
|
||||
local parent2 = parent1:GetParent()
|
||||
local ctrldown = love.keyboard.isDown("lctrl")
|
||||
local ctrldown = loveframes.util.IsCtrlDown()
|
||||
parent2:SelectRow(self, ctrldown)
|
||||
end
|
||||
|
||||
|
@ -135,10 +135,8 @@ function newobject:update(dt)
|
||||
|
||||
-- keydown check
|
||||
if keydown ~= "none" then
|
||||
local lctrl = love.keyboard.isDown("lctrl")
|
||||
local rctrl = love.keyboard.isDown("rctrl")
|
||||
if time > delay then
|
||||
if (lctrl or rctrl) and keydown == "v" then
|
||||
if (loveframes.util.IsCtrlDown()) and keydown == "v" then
|
||||
self:Paste()
|
||||
else
|
||||
self:RunKey(keydown, unicode, true)
|
||||
@ -475,8 +473,6 @@ function newobject:keypressed(key, unicode)
|
||||
end
|
||||
|
||||
local time = love.timer.getTime()
|
||||
local lctrl = love.keyboard.isDown("lctrl")
|
||||
local rctrl = love.keyboard.isDown("rctrl")
|
||||
local focus = self.focus
|
||||
local repeatdelay = self.repeatdelay
|
||||
local alltextselected = self.alltextselected
|
||||
@ -486,7 +482,7 @@ function newobject:keypressed(key, unicode)
|
||||
self.delay = time + repeatdelay
|
||||
self.keydown = key
|
||||
|
||||
if (lctrl or rctrl) and focus then
|
||||
if (loveframes.util.IsCtrlDown()) and focus then
|
||||
if key == "a" then
|
||||
self.alltextselected = true
|
||||
elseif key == "c" and alltextselected and version == "0.9.0" then
|
||||
@ -496,6 +492,15 @@ function newobject:keypressed(key, unicode)
|
||||
if oncopy then
|
||||
oncopy(self, text)
|
||||
end
|
||||
elseif key == "x" and alltextselected and version == "0.9.0" and editable then
|
||||
local text = self:GetText()
|
||||
local oncut = self.OnCut
|
||||
love.system.setClipboardText(text)
|
||||
if oncut then
|
||||
oncut(self, text)
|
||||
else
|
||||
self:SetText("")
|
||||
end
|
||||
elseif key == "v" and version == "0.9.0" and editable then
|
||||
self:Paste()
|
||||
end
|
||||
|
13
util.lua
13
util.lua
@ -361,3 +361,16 @@ function loveframes.util.GetHoverObject()
|
||||
return loveframes.hoverobject
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: loveframes.util.IsCtrlDown()
|
||||
- desc: checks for ctrl, for use with multiselect, copy,
|
||||
paste, and such. On OS X it actually looks for cmd.
|
||||
--]]---------------------------------------------------------
|
||||
function loveframes.util.IsCtrlDown()
|
||||
if love._os == "OS X" then
|
||||
return love.keyboard.isDown("lmeta") or love.keyboard.isDown("rmeta") or
|
||||
love.keyboard.isDown("lgui") or love.keyboard.isDown("rgui")
|
||||
end
|
||||
return love.keyboard.isDown("lctrl") or love.keyboard.isDown("rctrl")
|
||||
end
|
Loading…
Reference in New Issue
Block a user