mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
slight change to element:removeChild(), commented out ideas for window focusing
This commit is contained in:
parent
47f69d606e
commit
d530dfc5e0
@ -38,8 +38,7 @@ do
|
|||||||
else
|
else
|
||||||
for k, v in ipairs(self.child) do
|
for k, v in ipairs(self.child) do
|
||||||
if v == child then
|
if v == child then
|
||||||
remove(self.child, k)
|
return remove(self.child, k)
|
||||||
return self
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return "Element \"" .. tostring(child) .. "\" is not a child of element \"" .. tostring(self) .. "\". Cannot remove it."
|
return "Element \"" .. tostring(child) .. "\" is not a child of element \"" .. tostring(self) .. "\". Cannot remove it."
|
||||||
|
@ -38,8 +38,7 @@ do
|
|||||||
else
|
else
|
||||||
for k, v in ipairs(self.child) do
|
for k, v in ipairs(self.child) do
|
||||||
if v == child then
|
if v == child then
|
||||||
remove(self.child, k)
|
return remove(self.child, k)
|
||||||
return self
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return "Element \"" .. tostring(child) .. "\" is not a child of element \"" .. tostring(self) .. "\". Cannot remove it."
|
return "Element \"" .. tostring(child) .. "\" is not a child of element \"" .. tostring(self) .. "\". Cannot remove it."
|
||||||
|
@ -51,7 +51,8 @@ class element
|
|||||||
|
|
||||||
return @
|
return @
|
||||||
|
|
||||||
-- remove child by index and return it OR remove child by reference
|
-- remove child by index OR by reference and return it
|
||||||
|
--NOTE API CHANGE HERE MIGHT'VE FUCKED A THING
|
||||||
removeChild: (child) =>
|
removeChild: (child) =>
|
||||||
if tonumber(child) == child
|
if tonumber(child) == child
|
||||||
-- remove indexed child, return it
|
-- remove indexed child, return it
|
||||||
@ -60,13 +61,16 @@ class element
|
|||||||
else
|
else
|
||||||
for k,v in ipairs @child
|
for k,v in ipairs @child
|
||||||
if v == child
|
if v == child
|
||||||
remove @child, k
|
return remove @child, k
|
||||||
return @
|
|
||||||
return "Element \"#{child}\" is not a child of element \"#{@}\". Cannot remove it."
|
return "Element \"#{child}\" is not a child of element \"#{@}\". Cannot remove it."
|
||||||
|
|
||||||
getChildren: =>
|
getChildren: =>
|
||||||
return @child
|
return @child
|
||||||
|
|
||||||
|
--focusChild: (child) =>
|
||||||
|
-- insert @child, 1, @removeChild(child)
|
||||||
|
-- return @
|
||||||
|
|
||||||
move: (x, y) =>
|
move: (x, y) =>
|
||||||
if x
|
if x
|
||||||
@x = @x + x
|
@x = @x + x
|
||||||
|
@ -104,6 +104,10 @@ class window extends element
|
|||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
--@head.focusChild = =>
|
||||||
|
-- @parent\focusChild @ -- nope
|
||||||
|
-- return @
|
||||||
|
|
||||||
debugDraw: =>
|
debugDraw: =>
|
||||||
graphics.setLineWidth 0.5
|
graphics.setLineWidth 0.5
|
||||||
graphics.setColor 0, 0, 0, 100
|
graphics.setColor 0, 0, 0, 100
|
||||||
@ -137,6 +141,11 @@ class window extends element
|
|||||||
getChildren: =>
|
getChildren: =>
|
||||||
return @area.child
|
return @area.child
|
||||||
|
|
||||||
|
--focusChild: =>
|
||||||
|
-- @parent\focusChild @
|
||||||
|
-- --NOTE might need to also actually focus the sub-element
|
||||||
|
-- return @
|
||||||
|
|
||||||
align: (horizontal, vertical, toPixel) =>
|
align: (horizontal, vertical, toPixel) =>
|
||||||
super horizontal, vertical, toPixel
|
super horizontal, vertical, toPixel
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ pop.mousepressed = (x, y, button, element) ->
|
|||||||
if handled = element\mousepressed x - element.x, y - element.y, button
|
if handled = element\mousepressed x - element.x, y - element.y, button
|
||||||
pop.focused = element
|
pop.focused = element
|
||||||
|
|
||||||
-- have we handled the event?
|
-- return whether or not we have handled the event
|
||||||
return handled
|
return handled
|
||||||
|
|
||||||
pop.mousereleased = (x, y, button, element) ->
|
pop.mousereleased = (x, y, button, element) ->
|
||||||
@ -165,6 +165,10 @@ pop.mousereleased = (x, y, button, element) ->
|
|||||||
-- if we clicked, we're focused!
|
-- if we clicked, we're focused!
|
||||||
if clickedHandled
|
if clickedHandled
|
||||||
pop.focused = element
|
pop.focused = element
|
||||||
|
--NOTE this might cause an error in the above for loop!
|
||||||
|
-- basically, move focused element to front of its parent's child
|
||||||
|
--element.parent\focusChild element
|
||||||
|
--table.insert element.parent, element.parent\removeChild(element),
|
||||||
|
|
||||||
-- else, default to pop.screen to begin! (and print that we received an event)
|
-- else, default to pop.screen to begin! (and print that we received an event)
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user