attempted #65, failed

This commit is contained in:
Paul Liverman III 2017-08-13 18:50:54 -07:00
parent ab232862cb
commit 727b953d6d
4 changed files with 23 additions and 0 deletions

View File

@ -1,3 +1,4 @@
local pop
local graphics
graphics = love.graphics
local floor, max
@ -11,6 +12,9 @@ local element
do
local _class_0
local _base_0 = {
load = function(pop_lib)
pop = pop_lib
end,
align = function(self, horizontal, vertical, toPixel)
if toPixel == nil then
toPixel = true
@ -206,6 +210,10 @@ do
return self
end,
delete = function(self)
if self == pop.hovered then
pop.hovered = false
pop.log(tostring(self) .. " (" .. tostring(self.type) .. ") unfocused (deleted)")
end
for i = #self.child, 1, -1 do
self.child[i]:delete()
end

View File

@ -3,11 +3,16 @@
--- @copyright Paul Liverman III (2016)
--- @license The MIT License (MIT)
local pop
import graphics from love
import floor, max from math
import inheritsFromElement from require "#{(...)\sub 1, -19}/util"
class element
load: (pop_lib) ->
pop = pop_lib
--- Constructor expects nothing, or a data table describing it.
--- @tparam ?Element|false parent The parent element.
--- @tparam table data[opt] The data (state) for this element.
@ -253,6 +258,12 @@ class element
--- Deletes references to this element and then deletes it.
delete: =>
-- does not work for desired issue, element is still referenced and set as focused after this would be called
-- however, it is probably a good idea for anything being deleted to make sure it isn't focused
if @ == pop.hovered
pop.hovered = false
pop.log "#{@} (#{@type}) unfocused (deleted)"
for i=#@child, 1, -1
@child[i]\delete!

View File

@ -197,6 +197,8 @@ love.keypressed = function(key)
return love.event.quit()
elseif key == "d" then
debug = not debug
elseif key == "t" then
return print("pop.focused", pop.focused)
end
end
love.keyreleased = function(key)

View File

@ -80,6 +80,8 @@ love.keypressed = (key) ->
love.event.quit!
elseif key == "d"
debug = not debug
elseif key == "t"
print("pop.focused", pop.focused)
love.keyreleased = (key) ->
pop.keyreleased key