BEMCheckBox icon indicating copy to clipboard operation
BEMCheckBox copied to clipboard

Add delegate function "ShouldChange"

Open Oggerschummer opened this issue 4 years ago • 1 comments

Hi, may I propose some enhancement: It would be beneficial to have a delegate function like "shouldChange" with Bool result that gets called just before any state change (selected, unselected) happens triggered form UI. In case the delegate returns false, no change happens and the box stays as it is. Default behaviour: Allow changes. Something similar is available e.g. for UITextField. I have situations, where I need to run checks or calculations before allowing to switch the state. In addition the state sometimes is populated from a popup where multiple entries are required to allow the state become true - clicking on the checkbox with this delegate function would allow me to trigger the popup easily and avoid the user being able to manually check the box. Would keep things simple and avoid having to work with additional gesture recognizers above the box. Regards Oggerschummer

Oggerschummer avatar Apr 29 '20 07:04 Oggerschummer

This is a good idea, and it should be fairly trivial to implement. We need to make sure that this delegate function is optional.

Feel free to contribute to the codebase by opening a PR @Oggerschummer!

Boris-Em avatar Oct 02 '20 12:10 Boris-Em