Re: Gspöt - retained GUI lib
Posted: Fri Feb 12, 2021 5:04 am
Visual behavior for buttons is a bit weird and unintuitive and lacks any detection of "being mouseddown" in collaboration with the new mouserelease version of click. I've modified the Gspot.button.draw function as so (feel free to collapse the indentation):
For regular buttons:
- default = style.default
- mouseover = style.hilite
- mousedown = style.focus
For a toggled button (like Option):
- default = style.hilite
- mouseover = style.focus
- mousedown = style.default
I've added a check for "this.value ~= nil" to fix (what I believe to be) the bug that causes regular buttons to change their color behavior when they are parented to another object. Only buttons which have an explicit this.value property will change their color behavior.
Code: Select all
draw = function(this, pos)
if this.parent and this.value ~= nil and this.value == this.parent.value then
if this == this.Gspot.mousein then
if love.mouse.isDown(1) or love.mouse.isDown(2) then
setColor(this.style.default)
else
setColor(this.style.focus)
end
else
setColor(this.style.hilite)
end
else
if this == this.Gspot.mousein then
if love.mouse.isDown(1) or love.mouse.isDown(2) then
setColor(this.style.focus)
else
setColor(this.style.hilite)
end
else
setColor(this.style.default)
end
end
-- insert the rest of the code here
end
- default = style.default
- mouseover = style.hilite
- mousedown = style.focus
For a toggled button (like Option):
- default = style.hilite
- mouseover = style.focus
- mousedown = style.default
I've added a check for "this.value ~= nil" to fix (what I believe to be) the bug that causes regular buttons to change their color behavior when they are parented to another object. Only buttons which have an explicit this.value property will change their color behavior.