Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ColorPicker - optional alpha value passing and return value use int instead of string #69

Closed
wants to merge 8 commits into from

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
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant