diff --git a/elements/window.moon b/elements/window.moon index f6e35c6..e803f8f 100644 --- a/elements/window.moon +++ b/elements/window.moon @@ -81,6 +81,8 @@ class window extends element @window_area.clicked = => return nil + --print "window_area " .. tostring @window_area + selected = false mx = 0 my = 0 diff --git a/init.lua b/init.lua index b496bcc..c453fca 100644 --- a/init.lua +++ b/init.lua @@ -252,7 +252,7 @@ pop.mousepressed = function(x, y, button, element) end if element.mousepressed then handled = element:mousepressed(x - element.data.x, y - element.data.y, button) - if handled ~= false then + if handled then pop.focused = element end end @@ -359,6 +359,9 @@ pop.debugDraw = function(element) if element == nil then element = pop.screen end + if element.debugDraw then + element:debugDraw() + end graphics.setLineWidth(1) graphics.setColor(0, 0, 0, 100) graphics.rectangle("fill", element.data.x, element.data.y, element.data.w, element.data.h) diff --git a/init.moon b/init.moon index f452b8d..6d59c10 100644 --- a/init.moon +++ b/init.moon @@ -323,7 +323,7 @@ pop.mousepressed = (x, y, button, element) -> -- if a child hasn't handled it yet, try to handle it, and set pop.focused if element.mousepressed handled = element\mousepressed x - element.data.x, y - element.data.y, button - if handled != false + if handled -- you have to explicitly handle a mousepressed event to become focused pop.focused = element -- return whether or not we have handled the event @@ -385,10 +385,13 @@ pop.mousereleased = (x, y, button, element) -> if element.mousereleased mousereleasedHandled = element\mousereleased x - element.data.x, y - element.data.y, button if clickedHandled != false or mousereleasedHandled != false + --print "#{clickedHandled}, #{mousereleasedHandled}, #{element}, #{element.data.type}" return clickedHandled, mousereleasedHandled pop.mousereleased x, y, button, pop.screen + --print "#{clickedHandled}, #{mousereleasedHandled}, #{element}" + return clickedHandled, mousereleasedHandled @@ -489,7 +492,9 @@ pop.export = (element=pop.screen) -> --- @see Element pop.debugDraw = (element=pop.screen) -> - --@todo Remove element.debugDraw functions. + if element.debugDraw + element\debugDraw! + graphics.setLineWidth 1 graphics.setColor 0, 0, 0, 100 graphics.rectangle "fill", element.data.x, element.data.y, element.data.w, element.data.h