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
|
local graphics
|
||||||
graphics = love.graphics
|
graphics = love.graphics
|
||||||
local floor, max
|
local floor, max
|
||||||
@ -11,6 +12,9 @@ local element
|
|||||||
do
|
do
|
||||||
local _class_0
|
local _class_0
|
||||||
local _base_0 = {
|
local _base_0 = {
|
||||||
|
load = function(pop_lib)
|
||||||
|
pop = pop_lib
|
||||||
|
end,
|
||||||
align = function(self, horizontal, vertical, toPixel)
|
align = function(self, horizontal, vertical, toPixel)
|
||||||
if toPixel == nil then
|
if toPixel == nil then
|
||||||
toPixel = true
|
toPixel = true
|
||||||
@ -206,6 +210,10 @@ do
|
|||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
delete = function(self)
|
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
|
for i = #self.child, 1, -1 do
|
||||||
self.child[i]:delete()
|
self.child[i]:delete()
|
||||||
end
|
end
|
||||||
|
@ -3,11 +3,16 @@
|
|||||||
--- @copyright Paul Liverman III (2016)
|
--- @copyright Paul Liverman III (2016)
|
||||||
--- @license The MIT License (MIT)
|
--- @license The MIT License (MIT)
|
||||||
|
|
||||||
|
local pop
|
||||||
|
|
||||||
import graphics from love
|
import graphics from love
|
||||||
import floor, max from math
|
import floor, max from math
|
||||||
import inheritsFromElement from require "#{(...)\sub 1, -19}/util"
|
import inheritsFromElement from require "#{(...)\sub 1, -19}/util"
|
||||||
|
|
||||||
class element
|
class element
|
||||||
|
load: (pop_lib) ->
|
||||||
|
pop = pop_lib
|
||||||
|
|
||||||
--- Constructor expects nothing, or a data table describing it.
|
--- Constructor expects nothing, or a data table describing it.
|
||||||
--- @tparam ?Element|false parent The parent element.
|
--- @tparam ?Element|false parent The parent element.
|
||||||
--- @tparam table data[opt] The data (state) for this 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.
|
--- Deletes references to this element and then deletes it.
|
||||||
delete: =>
|
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
|
for i=#@child, 1, -1
|
||||||
@child[i]\delete!
|
@child[i]\delete!
|
||||||
|
|
||||||
|
2
main.lua
2
main.lua
@ -197,6 +197,8 @@ love.keypressed = function(key)
|
|||||||
return love.event.quit()
|
return love.event.quit()
|
||||||
elseif key == "d" then
|
elseif key == "d" then
|
||||||
debug = not debug
|
debug = not debug
|
||||||
|
elseif key == "t" then
|
||||||
|
return print("pop.focused", pop.focused)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
love.keyreleased = function(key)
|
love.keyreleased = function(key)
|
||||||
|
@ -80,6 +80,8 @@ love.keypressed = (key) ->
|
|||||||
love.event.quit!
|
love.event.quit!
|
||||||
elseif key == "d"
|
elseif key == "d"
|
||||||
debug = not debug
|
debug = not debug
|
||||||
|
elseif key == "t"
|
||||||
|
print("pop.focused", pop.focused)
|
||||||
|
|
||||||
love.keyreleased = (key) ->
|
love.keyreleased = (key) ->
|
||||||
pop.keyreleased key
|
pop.keyreleased key
|
||||||
|
Loading…
Reference in New Issue
Block a user