Create an action for the button to switch to the selected state