diff --git a/docs/classes/element.html b/docs/classes/element.html index e03eb6d..878a387 100644 --- a/docs/classes/element.html +++ b/docs/classes/element.html @@ -426,7 +426,7 @@
generated by LDoc 1.4.3 -Last updated 2017-04-10 22:47:43 +Last updated 2017-04-11 01:22:59
diff --git a/docs/classes/window.html b/docs/classes/window.html index f4ddff8..eff8804 100644 --- a/docs/classes/window.html +++ b/docs/classes/window.html @@ -144,7 +144,7 @@
generated by LDoc 1.4.3 -Last updated 2017-04-10 22:47:43 +Last updated 2017-04-11 01:22:59
diff --git a/docs/index.html b/docs/index.html index 51786a1..206501d 100644 --- a/docs/index.html +++ b/docs/index.html @@ -84,7 +84,7 @@
generated by LDoc 1.4.3 -Last updated 2017-04-10 22:47:43 +Last updated 2017-04-11 01:22:59
diff --git a/docs/modules/Element.html b/docs/modules/Element.html index 1f4208b..e92b3d8 100644 --- a/docs/modules/Element.html +++ b/docs/modules/Element.html @@ -491,7 +491,7 @@
generated by LDoc 1.4.3 -Last updated 2017-04-10 22:47:43 +Last updated 2017-04-11 01:22:59
diff --git a/docs/modules/main.html b/docs/modules/main.html index 3a041e0..f713f86 100644 --- a/docs/modules/main.html +++ b/docs/modules/main.html @@ -105,7 +105,7 @@
generated by LDoc 1.4.3 -Last updated 2017-04-10 22:47:43 +Last updated 2017-04-11 01:22:59
diff --git a/docs/modules/pop.html b/docs/modules/pop.html index 0538601..940b6d3 100644 --- a/docs/modules/pop.html +++ b/docs/modules/pop.html @@ -723,7 +723,7 @@ table.insert element.parent, element.parent\removeChild(element),
generated by LDoc 1.4.3 -Last updated 2017-04-10 22:47:43 +Last updated 2017-04-11 01:22:59
diff --git a/docs/modules/util.html b/docs/modules/util.html index 7799c03..6bc07da 100644 --- a/docs/modules/util.html +++ b/docs/modules/util.html @@ -126,7 +126,7 @@
generated by LDoc 1.4.3 -Last updated 2017-04-10 22:47:43 +Last updated 2017-04-11 01:22:59
diff --git a/init.lua b/init.lua index 95d2db3..a384d25 100644 --- a/init.lua +++ b/init.lua @@ -213,9 +213,9 @@ pop.mousemoved = function(x, y, dx, dy, element) if element == nil then element = pop.screen end - if (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h) then + if element.data.draw and (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h) then pop.hovered = element - for i = #element.child, 1, -1 do + for i = 1, #element.child do pop.mousemoved(x, y, dx, dy, element.child[i]) end end @@ -230,8 +230,8 @@ pop.mousepressed = function(x, y, button, element) element = pop.screen end local handled = false - if (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h) then - for i = #element.child, 1, -1 do + if element.data.draw and (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h) then + for i = 1, #element.child do do handled = pop.mousepressed(x, y, button, element.child[i]) if handled then @@ -240,7 +240,7 @@ pop.mousepressed = function(x, y, button, element) end end if not (handled) then - if element.mousepressed and element.data.draw then + if element.mousepressed then do handled = element:mousepressed(x - element.data.x, y - element.data.y, button) if handled then @@ -257,14 +257,14 @@ pop.mousereleased = function(x, y, button, element) local mousereleasedHandled = false if element then if element.data.draw and (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h) then - for i = #element.child, 1, -1 do + for i = 1, #element.child do clickedHandled, mousereleasedHandled = pop.mousereleased(x, y, button, element.child[i]) if clickedHandled or mousereleasedHandled then return clickedHandled, mousereleasedHandled end end if not (clickedHandled or mousereleasedHandled) then - if element.clicked and element.data.draw then + if element.clicked then clickedHandled = element:clicked(x - element.data.x, y - element.data.y, button) end if element.mousereleased then diff --git a/init.moon b/init.moon index 6282e98..2ab959a 100644 --- a/init.moon +++ b/init.moon @@ -267,11 +267,11 @@ pop.draw = (element=pop.screen) -> pop.mousemoved = (x, y, dx, dy, element=pop.screen) -> -- first we find out if we're hovering over anything and set pop.hovered - if (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h) + if element.data.draw and (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h) -- okay, we're over this element for sure, but let's check its children pop.hovered = element -- check in reverse order, it will set pop.hovered to any that match - for i = #element.child, 1, -1 + for i = 1, #element.child pop.mousemoved x, y, dx, dy, element.child[i] --- @todo Implement a way for an element to attach itself to `love.mousemoved()` events? @@ -304,16 +304,16 @@ pop.mousepressed = (x, y, button, element) -> handled = false -- if it is inside the current element.. - if (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h) + if element.data.draw and (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h) -- check its child elements in reverse order, returning if something handles it - for i = #element.child, 1, -1 + for i = 1, #element.child 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 and are visible, try to handle it, and set pop.focused - if element.mousepressed and element.data.draw + -- 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 @@ -343,15 +343,14 @@ pop.mousereleased = (x, y, button, element) -> if element if element.data.draw and (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h) -- check its children in reverse for handling a clicked or mousereleased event - for i = #element.child, 1, -1 + for i = 1, #element.child clickedHandled, mousereleasedHandled = pop.mousereleased x, y, button, element.child[i] 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 - -- clicked only happens on visible elements, mousereleased happens either way - if element.clicked and element.data.draw + 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