mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
removed unneeded checks in mouse handling
This commit is contained in:
parent
65f9715f99
commit
3fb4b15241
30
init.lua
30
init.lua
@ -246,13 +246,11 @@ pop.mousepressed = function(x, y, button, element)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not (handled) then
|
if element.mousepressed then
|
||||||
if element.mousepressed then
|
do
|
||||||
do
|
handled = element:mousepressed(x - element.data.x, y - element.data.y, button)
|
||||||
handled = element:mousepressed(x - element.data.x, y - element.data.y, button)
|
if handled then
|
||||||
if handled then
|
pop.focused = element
|
||||||
pop.focused = element
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -270,16 +268,14 @@ pop.mousereleased = function(x, y, button, element)
|
|||||||
return clickedHandled, mousereleasedHandled
|
return clickedHandled, mousereleasedHandled
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not (clickedHandled or mousereleasedHandled) then
|
if element.clicked then
|
||||||
if element.clicked then
|
clickedHandled = element:clicked(x - element.data.x, y - element.data.y, button)
|
||||||
clickedHandled = element:clicked(x - element.data.x, y - element.data.y, button)
|
end
|
||||||
end
|
if element.mousereleased then
|
||||||
if element.mousereleased then
|
mousereleasedHandled = element:mousereleased(x - element.data.x, y - element.data.y, button)
|
||||||
mousereleasedHandled = element:mousereleased(x - element.data.x, y - element.data.y, button)
|
end
|
||||||
end
|
if clickedHandled then
|
||||||
if clickedHandled then
|
pop.focused = element
|
||||||
pop.focused = element
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
39
init.moon
39
init.moon
@ -318,12 +318,10 @@ pop.mousepressed = (x, y, button, element) ->
|
|||||||
if handled = pop.mousepressed x, y, button, element.child[i]
|
if handled = pop.mousepressed x, y, button, element.child[i]
|
||||||
return handled
|
return handled
|
||||||
|
|
||||||
-- if a child hasn't handled it yet (note: this check doesn't seem neccessary)
|
-- if a child hasn't handled it yet, try to handle it, and set pop.focused
|
||||||
unless handled
|
if element.mousepressed
|
||||||
-- if we can handle it, try to handle it, and set pop.focused
|
if handled = element\mousepressed x - element.data.x, y - element.data.y, button
|
||||||
if element.mousepressed
|
pop.focused = element
|
||||||
if handled = element\mousepressed x - element.data.x, y - element.data.y, button
|
|
||||||
pop.focused = element
|
|
||||||
|
|
||||||
-- return whether or not we have handled the event
|
-- return whether or not we have handled the event
|
||||||
return handled
|
return handled
|
||||||
@ -356,22 +354,21 @@ pop.mousereleased = (x, y, button, element) ->
|
|||||||
if clickedHandled or mousereleasedHandled
|
if clickedHandled or mousereleasedHandled
|
||||||
return clickedHandled, mousereleasedHandled
|
return clickedHandled, mousereleasedHandled
|
||||||
|
|
||||||
-- if that doesn't work, we try to handle it ourselves (note: again, this check seems unneccessary)
|
-- if that doesn't work, we try to handle it ourselves
|
||||||
unless clickedHandled or mousereleasedHandled
|
if element.clicked
|
||||||
if element.clicked
|
clickedHandled = element\clicked x - element.data.x, y - element.data.y, button
|
||||||
clickedHandled = element\clicked x - element.data.x, y - element.data.y, button
|
if element.mousereleased
|
||||||
if element.mousereleased
|
mousereleasedHandled = element\mousereleased x - element.data.x, y - element.data.y, button
|
||||||
mousereleasedHandled = element\mousereleased x - element.data.x, y - element.data.y, button
|
|
||||||
|
|
||||||
-- if we clicked, we're focused!
|
-- if we clicked, we're focused!
|
||||||
if clickedHandled
|
if clickedHandled
|
||||||
pop.focused = element
|
pop.focused = element
|
||||||
--- @todo Figure out how to bring a focused element to the front of view (aka the first element in its parent's children).
|
--- @todo Figure out how to bring a focused element to the front of view (aka the first element in its parent's children).
|
||||||
--- (If I do it right here, the for loop above may break! I need to test/figure this out.)
|
--- (If I do it right here, the for loop above may break! I need to test/figure this out.)
|
||||||
--NOTE this might cause an error in the above for loop!
|
--NOTE this might cause an error in the above for loop!
|
||||||
-- basically, move focused element to front of its parent's child
|
-- basically, move focused element to front of its parent's child
|
||||||
--element.parent\focusChild element
|
--element.parent\focusChild element
|
||||||
--table.insert element.parent, element.parent\removeChild(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