Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Missing function to bind switch state (lv_switch_bind_checked) #5902

Closed
xamix opened this issue Mar 18, 2024 · 5 comments
Closed

Missing function to bind switch state (lv_switch_bind_checked) #5902

xamix opened this issue Mar 18, 2024 · 5 comments
Labels

Comments

@xamix
Copy link

xamix commented Mar 18, 2024

LVGL version

v9.0.0

What happened?

I can find the lv_button_bind_checked for buttons but not the equivalent for switch (lv_switch_bind_checked)
Is this function missing or do I need to use another function?
I tryed lv_button_bind_checked on a switch and it seem to work...

Regards

How to reproduce?

No response

@kisvegabor
Copy link
Member

Actually lv_button_bind_checked should work for buttons, switches and checkboxes too. It just binds the LV_STATE_CHECKED state of the widget. I think we should rather call this function lv_obj_bind_checked. What do you think?

cc @liamHowatt

@liamHowatt
Copy link
Collaborator

liamHowatt commented Mar 18, 2024

Switch and checkbox are checkable by default. lv_obj_add_flag(btn, LV_OBJ_FLAG_CHECKABLE) is needed before lv_button_bind_checked on a button. Meanwhile lv_button_bind_checked works "out of the box" on checkboxes. Since there's nothing about the implementation of lv_button_bind_checked that relies on anything button-specific, and works "out of the box" on those widgets other than button, yes I think it's a good idea to rename it to lv_obj_bind_checked.

Might be good to mention the LV_OBJ_FLAG_CHECKABLE flag in the docstring of lv_obj_bind_checked.

@kisvegabor
Copy link
Member

@liamHowatt It seems all good. Could you send a PR?

@lvgl-bot
Copy link

lvgl-bot commented Apr 5, 2024

We need some feedback on this issue.

Now we mark this as "stale" because there was no activity here for 14 days.

Remove the "stale" label or comment else this will be closed in 7 days.

@lvgl-bot lvgl-bot added the stale label Apr 5, 2024
@kisvegabor
Copy link
Member

The Pull request is merged. Closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants