mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
attempted #65, failed
This commit is contained in:
parent
ab232862cb
commit
727b953d6d
@ -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
|
||||
|
@ -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!
|
||||
|
||||
|
2
main.lua
2
main.lua
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user