textinput custom cursor fixes

Updated the textinput custom cursor code to use the newest 0.9.0 cursor
functions
Fixed textinput custom cursors not being reset in certain situations
loveframes.hoverobject is now used to reference the currently hovered
object
loveframes.downobject has been added to assume the previous role of
loveframes.hoverobject
This commit is contained in:
Kenny Shields 2013-10-30 19:05:10 -04:00
parent a46a6d697c
commit 072918fbea
18 changed files with 79 additions and 60 deletions

View File

@ -18,6 +18,7 @@ Version 0.9.6.4 - Alpha (Release Date TBD)
[ADDED] basic clipboard support for the textinput object (0.9.0 only)
[ADDED] custom cursor support for the textinput object
[ADDED] support for love.filesystem changes to loveframes.util.GetDirectoryContents (0.9.0 only)
[ADDED] loveframes.downobject
[FIXED] error when pressing a function key while a textinput was focused
[FIXED] the tooltip object not setting the state of its text object
@ -27,6 +28,7 @@ Version 0.9.6.4 - Alpha (Release Date TBD)
[CHANGED] cleaned up the tooltip object
[CHANGED] upgraded to middleclass 3.0
[CHANGED] loveframes.hoverobject is now used to store the currently hovered object
================================================
Version 0.9.6.3 - Alpha (August 15 - 2013)

View File

@ -28,7 +28,10 @@ loveframes.collisioncount = 0
loveframes.hoverobject = false
loveframes.modalobject = false
loveframes.inputobject = false
loveframes.downobject = false
loveframes.hover = false
loveframes.input_cursor_set = false
loveframes.prevcursor = nil
loveframes.basicfont = love.graphics.newFont(12)
loveframes.basicfontsmall = love.graphics.newFont(10)
loveframes.objects = {}
@ -98,10 +101,40 @@ end
function loveframes.update(dt)
local base = loveframes.base
local input_cursor_set = loveframes.input_cursor_set
local version = love._version
loveframes.collisioncount = 0
loveframes.hover = false
loveframes.hoverobject = false
base:update(dt)
if version == "0.9.0" then
local hoverobject = loveframes.hoverobject
if hoverobject then
if not input_cursor_set then
if hoverobject.type == "textinput" then
local curcursor = love.mouse.getCursor()
local newcursor = love.mouse.getSystemCursor("ibeam")
love.mouse.setCursor(newcursor)
loveframes.prevcursor = curcursor
loveframes.input_cursor_set = true
end
else
if hoverobject.type ~= "textinput" then
local prevcursor = loveframes.prevcursor
love.mouse.setCursor(prevcursor)
loveframes.input_cursor_set = false
end
end
else
if input_cursor_set then
local prevcursor = loveframes.prevcursor
love.mouse.setCursor(prevcursor)
loveframes.input_cursor_set = false
end
end
end
end
@ -150,7 +183,7 @@ function loveframes.mousereleased(x, y, button)
-- reset the hover object
if button == "l" then
loveframes.hoverobject = false
loveframes.downobject = false
loveframes.selectedobject = false
end

View File

@ -764,7 +764,7 @@ function newobject:CheckHover()
local x, y = love.mouse.getPosition()
local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height)
local hoverobject = loveframes.hoverobject
local downobject = loveframes.downobject
local modalobject = loveframes.modalobject
local collisioncount = loveframes.collisioncount
local clickbounds = self.clickbounds
@ -774,10 +774,10 @@ function newobject:CheckHover()
loveframes.collisioncount = collisioncount + 1
local top = self:IsTopCollision()
if top then
if not hoverobject then
if not downobject then
self.hover = true
else
if hoverobject == self then
if downobject == self then
self.hover = true
else
self.hover = false
@ -829,6 +829,10 @@ function newobject:CheckHover()
end
end
if self.hover and self.type ~= "base" then
loveframes.hoverobject = self
end
end
--[[---------------------------------------------------------

View File

@ -50,18 +50,18 @@ function newobject:update(dt)
local hover = self.hover
local down = self.down
local hoverobject = loveframes.hoverobject
local downobject = loveframes.downobject
local parent = self.parent
local base = loveframes.base
local update = self.Update
if not hover then
self.down = false
if hoverobject == self then
if downobject == self then
self.hover = true
end
else
if hoverobject == self then
if downobject == self then
self.down = true
end
end
@ -144,7 +144,7 @@ function newobject:mousepressed(x, y, button)
baseparent:MakeTop()
end
self.down = true
loveframes.hoverobject = self
loveframes.downobject = self
end
end

View File

@ -63,12 +63,12 @@ function newobject:update(dt)
if not hover then
self.down = false
else
if loveframes.hoverobject == self then
if loveframes.downobject == self then
self.down = true
end
end
if not self.down and loveframes.hoverobject == self then
if not self.down and loveframes.downobject == self then
self.hover = true
end
@ -175,7 +175,7 @@ function newobject:mousepressed(x, y, button)
baseparent:MakeTop()
end
self.down = true
loveframes.hoverobject = self
loveframes.downobject = self
end
end

View File

@ -156,7 +156,7 @@ function newobject:mousepressed(x, y, button)
baseparent:MakeTop()
end
self.down = true
loveframes.hoverobject = self
loveframes.downobject = self
end
end

View File

@ -50,7 +50,7 @@ function newobject:update(dt)
self:CheckHover()
local hover = self.hover
local hoverobject = loveframes.hoverobject
local downobject = loveframes.downobject
local down = self.down
local parent = self.parent
local base = loveframes.base
@ -59,12 +59,12 @@ function newobject:update(dt)
if not hover then
self.down = false
else
if hoverobject == self then
if downobject == self then
self.down = true
end
end
if not down and hoverobject == self then
if not down and downobject == self then
self.hover = true
end
@ -146,7 +146,7 @@ function newobject:mousepressed(x, y, button)
baseparent:MakeTop()
end
self.down = true
loveframes.hoverobject = self
loveframes.downobject = self
end
end

View File

@ -44,7 +44,7 @@ function newobject:update(dt)
local hover = self.hover
local down = self.down
local hoverobject = loveframes.hoverobject
local downobject = loveframes.downobject
local parent = self.parent
local base = loveframes.base
local update = self.Update
@ -52,12 +52,12 @@ function newobject:update(dt)
if not hover then
self.down = false
else
if loveframes.hoverobject == self then
if loveframes.downobject == self then
self.down = true
end
end
if not down and hoverobject == self then
if not down and downobject == self then
self.hover = true
end
@ -124,7 +124,7 @@ function newobject:mousepressed(x, y, button)
baseparent:MakeTop()
end
self.down = true
loveframes.hoverobject = self
loveframes.downobject = self
end
end

View File

@ -77,12 +77,12 @@ function newobject:update(dt)
if not self.hover then
self.down = false
else
if loveframes.hoverobject == self then
if loveframes.downobject == self then
self.down = true
end
end
if self.down and loveframes.hoverobject == self then
if self.down and loveframes.downobject == self then
self.hover = true
end
@ -142,7 +142,7 @@ function newobject:mousepressed(x, y, button)
baseparent:MakeTop()
end
self.down = true
loveframes.hoverobject = self
loveframes.downobject = self
end
end

View File

@ -50,12 +50,12 @@ function newobject:update(dt)
if not self.hover then
self.down = false
else
if loveframes.hoverobject == self then
if loveframes.downobject == self then
self.down = true
end
end
if not self.down and loveframes.hoverobject == self then
if not self.down and loveframes.downobject == self then
self.hover = true
end
@ -118,7 +118,7 @@ function newobject:mousepressed(x, y, button)
if hover and button == "l" then
self.down = true
loveframes.hoverobject = self
loveframes.downobject = self
end
end

View File

@ -193,7 +193,7 @@ function newobject:mousepressed(x, y, button)
bar:Scroll(-bar.width)
end
end
loveframes.hoverobject = self
loveframes.downobject = self
end
for k, v in ipairs(internals) do

View File

@ -249,7 +249,7 @@ function newobject:mousepressed(x, y, button)
self.clickx = x
self.clicky = y
self.dragging = true
loveframes.hoverobject = self
loveframes.downobject = self
end
end

View File

@ -50,12 +50,12 @@ function newobject:update(dt)
if not hover then
self.down = false
else
if loveframes.hoverobject == self then
if loveframes.downobject == self then
self.down = true
end
end
if not self.down and loveframes.hoverobject == self then
if not self.down and loveframes.downobject == self then
self.hover = true
end
@ -123,7 +123,7 @@ function newobject:mousepressed(x, y, button)
baseparent:MakeTop()
end
self.down = true
loveframes.hoverobject = self
loveframes.downobject = self
end
end

View File

@ -56,7 +56,7 @@ function newobject:update(dt)
local pvalue = self.parent.value
local hover = self.hover
local down = self.down
local hoverobject = loveframes.hoverobject
local downobject = loveframes.downobject
local parent = self.parent
local slidetype = parent.slidetype
local dragging = self.dragging
@ -65,16 +65,16 @@ function newobject:update(dt)
if not hover then
self.down = false
if hoverobject == self then
if downobject == self then
self.hover = true
end
else
if hoverobject == self then
if downobject == self then
self.down = true
end
end
if not down and hoverobject == self then
if not down and downobject == self then
self.hover = true
end
@ -116,7 +116,7 @@ function newobject:update(dt)
self.parent.OnValueChanged(self.parent, self.parent.value)
end
end
loveframes.hoverobject = self
loveframes.downobject = self
end
if slidetype == "horizontal" then
@ -200,7 +200,7 @@ function newobject:mousepressed(x, y, button)
self.clickx = x
self.starty = self.staticy
self.clicky = y
loveframes.hoverobject = self
loveframes.downobject = self
end
end

View File

@ -133,7 +133,7 @@ function newobject:mousepressed(x, y, button)
baseparent:MakeTop()
end
self.down = true
loveframes.hoverobject = self
loveframes.downobject = self
end
end

View File

@ -141,7 +141,7 @@ function newobject:mousepressed(x, y, button)
self.haslist = true
self.list = loveframes.objects["multichoicelist"]:new(self)
self.list:SetState(self.state)
loveframes.hoverobject = self
loveframes.downobject = self
end
end

View File

@ -60,9 +60,7 @@ function newobject:initialize()
self.editable = true
self.internal = false
self.autoscroll = false
self.cursorset = false
self.masked = false
self.prevcursor = nil
self.OnEnter = nil
self.OnTextChanged = nil
self.OnFocusGained = nil
@ -134,25 +132,6 @@ function newobject:update(dt)
self.alltextselected = false
end
if version == "0.9.0" then
local cursorset = self.cursorset
if hover then
if not cursorset then
local curcursor = love.mouse.getCursor()
local newcursor = love.mouse.newCursor("ibeam")
love.mouse.setCursor(newcursor)
self.prevcursor = curcursor
self.cursorset = true
end
else
if cursorset then
local prevcursor = self.prevcursor
love.mouse.setCursor(prevcursor)
self.cursorset = false
end
end
end
-- keydown check
if keydown ~= "none" then
local lctrl = love.keyboard.isDown("lctrl")

View File

@ -247,6 +247,7 @@ function loveframes.util.RemoveAll()
loveframes.base.internals = {}
loveframes.hoverobject = false
loveframes.downobject = false
loveframes.modalobject = false
loveframes.inputobject = false
loveframes.hover = false