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
|
||||
if not (handled) then
|
||||
if element.mousepressed then
|
||||
do
|
||||
handled = element:mousepressed(x - element.data.x, y - element.data.y, button)
|
||||
if handled then
|
||||
pop.focused = element
|
||||
end
|
||||
if element.mousepressed then
|
||||
do
|
||||
handled = element:mousepressed(x - element.data.x, y - element.data.y, button)
|
||||
if handled then
|
||||
pop.focused = element
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -270,16 +268,14 @@ pop.mousereleased = function(x, y, button, element)
|
||||
return clickedHandled, mousereleasedHandled
|
||||
end
|
||||
end
|
||||
if not (clickedHandled or mousereleasedHandled) then
|
||||
if element.clicked then
|
||||
clickedHandled = element:clicked(x - element.data.x, y - element.data.y, button)
|
||||
end
|
||||
if element.mousereleased then
|
||||
mousereleasedHandled = element:mousereleased(x - element.data.x, y - element.data.y, button)
|
||||
end
|
||||
if clickedHandled then
|
||||
pop.focused = element
|
||||
end
|
||||
if element.clicked then
|
||||
clickedHandled = element:clicked(x - element.data.x, y - element.data.y, button)
|
||||
end
|
||||
if element.mousereleased then
|
||||
mousereleasedHandled = element:mousereleased(x - element.data.x, y - element.data.y, button)
|
||||
end
|
||||
if clickedHandled then
|
||||
pop.focused = element
|
||||
end
|
||||
end
|
||||
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]
|
||||
return handled
|
||||
|
||||
-- if a child hasn't handled it yet (note: this check doesn't seem neccessary)
|
||||
unless handled
|
||||
-- if we can handle it, try to handle it, and set pop.focused
|
||||
if element.mousepressed
|
||||
if handled = element\mousepressed x - element.data.x, y - element.data.y, button
|
||||
pop.focused = element
|
||||
-- if a child hasn't handled it yet, try to handle it, and set pop.focused
|
||||
if element.mousepressed
|
||||
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 handled
|
||||
@ -356,22 +354,21 @@ pop.mousereleased = (x, y, button, element) ->
|
||||
if clickedHandled or mousereleasedHandled
|
||||
return clickedHandled, mousereleasedHandled
|
||||
|
||||
-- if that doesn't work, we try to handle it ourselves (note: again, this check seems unneccessary)
|
||||
unless clickedHandled or mousereleasedHandled
|
||||
if element.clicked
|
||||
clickedHandled = element\clicked x - element.data.x, y - element.data.y, button
|
||||
if element.mousereleased
|
||||
mousereleasedHandled = element\mousereleased x - element.data.x, y - element.data.y, button
|
||||
-- if that doesn't work, we try to handle it ourselves
|
||||
if element.clicked
|
||||
clickedHandled = element\clicked x - element.data.x, y - element.data.y, button
|
||||
if element.mousereleased
|
||||
mousereleasedHandled = element\mousereleased x - element.data.x, y - element.data.y, button
|
||||
|
||||
-- if we clicked, we're focused!
|
||||
if clickedHandled
|
||||
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).
|
||||
--- (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!
|
||||
-- basically, move focused element to front of its parent's child
|
||||
--element.parent\focusChild element
|
||||
--table.insert element.parent, element.parent\removeChild(element),
|
||||
-- if we clicked, we're focused!
|
||||
if clickedHandled
|
||||
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).
|
||||
--- (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!
|
||||
-- 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
|
||||
|
Loading…
Reference in New Issue
Block a user