fixed an issue with logging

This commit is contained in:
Paul Liverman III 2017-08-13 18:34:51 -07:00
parent 048e8c7961
commit f325ac0f96
4 changed files with 22 additions and 6 deletions

View File

@ -204,7 +204,8 @@ do
}, closeImage):align("right")
self.closeButton.clicked = function(self, x, y, button)
if button == pop.constants.left_mouse then
return self.parent:close()
self.parent:close()
return true
end
end
self.data.header_width_reduction = self.data.header_width_reduction + buttonSize
@ -218,7 +219,8 @@ do
}, maximizeImage):align("right")
self.maximizeButton.clicked = function(self, x, y, button)
if button == pop.constants.left_mouse then
return self.parent:maximize()
self.parent:maximize()
return true
end
end
self.data.header_width_reduction = self.data.header_width_reduction + buttonSize
@ -232,7 +234,8 @@ do
}, minimizeImage):align("right")
self.minimizeButton.clicked = function(self, x, y, button)
if button == pop.constants.left_mouse then
return self.parent:minimize()
self.parent:minimize()
return true
end
end
self.data.header_width_reduction = self.data.header_width_reduction + buttonSize

View File

@ -56,19 +56,21 @@ class window extends element
@closeButton.clicked = (x, y, button) =>
if button == pop.constants.left_mouse
@parent\close!
return true
@data.header_width_reduction += buttonSize
if @data.maximizeable
@maximizeButton = pop.box(@, {w: buttonSize, h: buttonSize, horizontalMargin: @data.header_width_reduction, type: "box (window maximize button)"}, maximizeImage)\align "right"
@maximizeButton.clicked = (x, y, button) =>
if button == pop.constants.left_mouse
@parent\maximize!
--return nil --probably not needed
return true
@data.header_width_reduction += buttonSize
if @data.minimizeable
@minimizeButton = pop.box(@, {w: buttonSize, h: buttonSize, horizontalMargin: @data.header_width_reduction, type: "box (window minimize button)"}, minimizeImage)\align "right"
@minimizeButton.clicked = (x, y, button) =>
if button == pop.constants.left_mouse
@parent\minimize!
return true
@data.header_width_reduction += buttonSize
height = @title\getHeight! + 1

View File

@ -306,10 +306,16 @@ pop.mousereleased = function(x, y, button, 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) then
if element.clicked then
clickedHandled = element:clicked(x - element.data.x, y - element.data.y, button)
if clickedHandled ~= false then
log(" " .. tostring(clickedHandled) .. " (click handled)", tostring(element) .. " (" .. tostring(element.data.type) .. ")")
end
end
end
if element.mousereleased then
mousereleasedHandled = element:mousereleased(x - element.data.x, y - element.data.y, button)
if mousereleasedHandled ~= false then
log(" " .. tostring(mousereleasedHandled) .. " (release handled)", tostring(element) .. " (" .. tostring(element.data.type) .. ")")
end
end
if clickedHandled ~= false or mousereleasedHandled ~= false then
return clickedHandled, mousereleasedHandled

View File

@ -282,9 +282,10 @@ pop.mousemoved = (x, y, dx, dy, element=pop.screen) ->
-- if we're hovering over something different, log it
if element == pop.screen and pop.hovered != previously_hovered
log " pop.hovered: #{pop.hovered} (#{pop.hovered.data.type})"
-- @todo This is where we call previously_hovered\hovered false, and pop.hovered\hovered true
-- There may be an issue where we are trying only on the lowest object in the hierarchy and we need to check multiple...
--- @todo Implement a way for an element to attach itself to `love.mousemoved()` events?
-- checking element against pop.screen so that this only gets called once
-- checks element == pop.screen so this only gets called once at the end of recursion
if pop.focused and pop.focused.mousemoved and element == pop.screen
return pop.focused\mousemoved x - pop.focused.data.x, y - pop.focused.data.y, dx, dy
@ -397,9 +398,13 @@ pop.mousereleased = (x, y, button, 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)
if element.clicked
clickedHandled = element\clicked x - element.data.x, y - element.data.y, button
if clickedHandled != false
log " #{clickedHandled} (click handled)", "#{element} (#{element.data.type})"
-- a focused element needs to know when it has been released no matter what!
if element.mousereleased
mousereleasedHandled = element\mousereleased x - element.data.x, y - element.data.y, button
if mousereleasedHandled != false
log " #{mousereleasedHandled} (release handled)", "#{element} (#{element.data.type})"
if clickedHandled != false or mousereleasedHandled != false
return clickedHandled, mousereleasedHandled