Skip to content

Conversation

@flamendless
Copy link
Owner

@flamendless flamendless commented Dec 19, 2020

This is useful for those who don't want to pass any 4th value (alpha) to the Color parameter.

I've encountered something weird:
in testing outside of my project (using Slab's own main.lua):

local color = {1, 1, 1} --no alpha

--in update
Slab.ColorPicker({Color = color}) -- no error

But in my project, the same thing is done:

local color = e.color.color -- a table of {1, 1, 1}
Slab.ColorPicker({Color = color}) -- gives error (ColorPicker.lua line 384) about a `nil` value, I assume the `CurrentColor[4]`

This PR fixes those.

@flamendless flamendless changed the title ColorPicker - optional alpha value passing ColorPicker - optional alpha value passing and return value use boolean instead of string Dec 19, 2020
@flamendless
Copy link
Owner Author

flamendless commented Dec 19, 2020

The 2nd commit of this PR changes:

local t = Slab.ColorPicker(...)
if t.Button == "OK" then ... end

to

local t = Slab.ColorPicker(...)
if t.Button == 1 then --okay
elseif t.Button == -1 then --cancel
end

As ColorPicker's buttons (according to the wiki API) are not customizable. So returning a boolean integer would suffice to check if the OK is pressed or not.

@flamendless flamendless changed the title ColorPicker - optional alpha value passing and return value use boolean instead of string ColorPicker - optional alpha value passing and return value use int instead of string Dec 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant