Jason Taylor avatar image
Jason Taylor asked

How can I disable an AlexaButton based on the state of a set of AlexaCheckboxes?

I have an APL Document that has a set of checkboxes that allow the user to record information in case not all the utterances were captured properly. I would like the button to be disabled if none of the Checkboxes are selected and enabled if one or more of them are checked. This seemed simple enough but apparently not... I've tried the following approaches to no avail:

  1. Referencing ${MyCheckbox.checked} property directly in the disabled state of the button - doesn't work
  2. Creating a bind variable to shadow the state of the checkboxes that I can reference in the disabled state of the button and/or send from checkboxes as a SetValue primaryAction - due to some interplay between my checkboxes (certain selections should auto-toggle other checkboxes) this gets out of sync with the actual state of the UI whether I use a counter to try and track checked checkboxes or some other construct to mimic state.
    1. I also tried hack a string with the states of the 5 Checkboxes to mirror what a bitmask would do and this got onerous quickly trying to splice and concatenate the string
    2. I also tried an array but although you can bind an array there does not seem to be a way to SetValue a specific array value. Either way I'd like to skip trying to mimic UI state and just access it directly to determine the button disable state

Am I missing something basic as it seems like a pretty standard thing to want to do on the UI?



alexa skills kitapl
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Andy Whitworth avatar image
Andy Whitworth answered

Had a little play and came up with this -> although this is basically your option 2 isn't it!

Anyway, I've put the document link up as others may have this use-case but without all the auto-selection thing that you have.

1 comment
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thanks! I couldn’t get this approach to work because I have a case where certain checkboxes SetValue to other checkboxes to set their checked property and I couldn’t find a way to ensure synchronicity of the bind variables state and the true state of the checkboxes. It seems like using SetValue to check a checkbox doesn’t trigger the primaryActions of the target checkbox. Is there really no way to access UI state directly? Seem like a waste to have to create bind variables and do a whole lot of primaryAction and SetValue coding just to handle a simple use case like this.
0 Likes 0 ·