SUIT doesn't adjust hit test for widgets inside canvases
Closed this issue · 2 comments
Placing SUIT buttons inside a canvas will draw (and scale and rotate) the buttons correctly, but will incorrectly interpret it's hit location.
For example; if you add the following to your update:
suit.ImageButton(image, {active=pressedImage}, 0, 0)
But do the following in your draw:
love.graphics.setCanvas(self.HUDCanvas)
suit.draw()
love.graphics.setCanvas()
love.graphics.draw(self.HUDCanvas, 100, 100)
Assume 'image' is 10x10 pixels. You will end up with a button drawn at position 100, 100 (correct), but with an active position of 0,0; 10,10
there's not really any way SUIT would know about the transformation of your draw, you'd have to pass it the mouse coordinates offset on your own.
@shakesoda is right, you have to tell SUIT that you draw the UI at a different position:
local mx,my = love.mouse.getPosition()
suid.updateMouse(mx+100, my+100)