mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
fixed an issue with logging
This commit is contained in:
parent
048e8c7961
commit
f325ac0f96
@ -204,7 +204,8 @@ do
|
|||||||
}, closeImage):align("right")
|
}, closeImage):align("right")
|
||||||
self.closeButton.clicked = function(self, x, y, button)
|
self.closeButton.clicked = function(self, x, y, button)
|
||||||
if button == pop.constants.left_mouse then
|
if button == pop.constants.left_mouse then
|
||||||
return self.parent:close()
|
self.parent:close()
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.data.header_width_reduction = self.data.header_width_reduction + buttonSize
|
self.data.header_width_reduction = self.data.header_width_reduction + buttonSize
|
||||||
@ -218,7 +219,8 @@ do
|
|||||||
}, maximizeImage):align("right")
|
}, maximizeImage):align("right")
|
||||||
self.maximizeButton.clicked = function(self, x, y, button)
|
self.maximizeButton.clicked = function(self, x, y, button)
|
||||||
if button == pop.constants.left_mouse then
|
if button == pop.constants.left_mouse then
|
||||||
return self.parent:maximize()
|
self.parent:maximize()
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.data.header_width_reduction = self.data.header_width_reduction + buttonSize
|
self.data.header_width_reduction = self.data.header_width_reduction + buttonSize
|
||||||
@ -232,7 +234,8 @@ do
|
|||||||
}, minimizeImage):align("right")
|
}, minimizeImage):align("right")
|
||||||
self.minimizeButton.clicked = function(self, x, y, button)
|
self.minimizeButton.clicked = function(self, x, y, button)
|
||||||
if button == pop.constants.left_mouse then
|
if button == pop.constants.left_mouse then
|
||||||
return self.parent:minimize()
|
self.parent:minimize()
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.data.header_width_reduction = self.data.header_width_reduction + buttonSize
|
self.data.header_width_reduction = self.data.header_width_reduction + buttonSize
|
||||||
|
@ -56,19 +56,21 @@ class window extends element
|
|||||||
@closeButton.clicked = (x, y, button) =>
|
@closeButton.clicked = (x, y, button) =>
|
||||||
if button == pop.constants.left_mouse
|
if button == pop.constants.left_mouse
|
||||||
@parent\close!
|
@parent\close!
|
||||||
|
return true
|
||||||
@data.header_width_reduction += buttonSize
|
@data.header_width_reduction += buttonSize
|
||||||
if @data.maximizeable
|
if @data.maximizeable
|
||||||
@maximizeButton = pop.box(@, {w: buttonSize, h: buttonSize, horizontalMargin: @data.header_width_reduction, type: "box (window maximize button)"}, maximizeImage)\align "right"
|
@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) =>
|
@maximizeButton.clicked = (x, y, button) =>
|
||||||
if button == pop.constants.left_mouse
|
if button == pop.constants.left_mouse
|
||||||
@parent\maximize!
|
@parent\maximize!
|
||||||
--return nil --probably not needed
|
return true
|
||||||
@data.header_width_reduction += buttonSize
|
@data.header_width_reduction += buttonSize
|
||||||
if @data.minimizeable
|
if @data.minimizeable
|
||||||
@minimizeButton = pop.box(@, {w: buttonSize, h: buttonSize, horizontalMargin: @data.header_width_reduction, type: "box (window minimize button)"}, minimizeImage)\align "right"
|
@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) =>
|
@minimizeButton.clicked = (x, y, button) =>
|
||||||
if button == pop.constants.left_mouse
|
if button == pop.constants.left_mouse
|
||||||
@parent\minimize!
|
@parent\minimize!
|
||||||
|
return true
|
||||||
@data.header_width_reduction += buttonSize
|
@data.header_width_reduction += buttonSize
|
||||||
|
|
||||||
height = @title\getHeight! + 1
|
height = @title\getHeight! + 1
|
||||||
|
6
init.lua
6
init.lua
@ -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.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
|
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)
|
||||||
|
if clickedHandled ~= false then
|
||||||
|
log(" " .. tostring(clickedHandled) .. " (click handled)", tostring(element) .. " (" .. tostring(element.data.type) .. ")")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
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)
|
||||||
|
if mousereleasedHandled ~= false then
|
||||||
|
log(" " .. tostring(mousereleasedHandled) .. " (release handled)", tostring(element) .. " (" .. tostring(element.data.type) .. ")")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if clickedHandled ~= false or mousereleasedHandled ~= false then
|
if clickedHandled ~= false or mousereleasedHandled ~= false then
|
||||||
return clickedHandled, mousereleasedHandled
|
return clickedHandled, mousereleasedHandled
|
||||||
|
@ -282,9 +282,10 @@ pop.mousemoved = (x, y, dx, dy, element=pop.screen) ->
|
|||||||
-- if we're hovering over something different, log it
|
-- if we're hovering over something different, log it
|
||||||
if element == pop.screen and pop.hovered != previously_hovered
|
if element == pop.screen and pop.hovered != previously_hovered
|
||||||
log " pop.hovered: #{pop.hovered} (#{pop.hovered.data.type})"
|
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?
|
-- checks element == pop.screen so this only gets called once at the end of recursion
|
||||||
-- checking element against pop.screen so that this only gets called once
|
|
||||||
if pop.focused and pop.focused.mousemoved and element == pop.screen
|
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
|
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.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
|
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 clickedHandled != false
|
||||||
|
log " #{clickedHandled} (click handled)", "#{element} (#{element.data.type})"
|
||||||
-- a focused element needs to know when it has been released no matter what!
|
-- a focused element needs to know when it has been released no matter what!
|
||||||
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 mousereleasedHandled != false
|
||||||
|
log " #{mousereleasedHandled} (release handled)", "#{element} (#{element.data.type})"
|
||||||
if clickedHandled != false or mousereleasedHandled != false
|
if clickedHandled != false or mousereleasedHandled != false
|
||||||
return clickedHandled, mousereleasedHandled
|
return clickedHandled, mousereleasedHandled
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user