TabBar - Disable Buttons

Other than laying something over them to catch and discard the event, how can you disable a tabbar (or each button individually)?

I took a quick look at the widget code and did not see any easy way to do this. I agree a disabled tab button would be a great thing to have. This almost needs a third button state image provision. Currently we have Unpressed and Pressed state images and to nicely disable a button we would need to change the button image as well right? I would be interested in this option in the widget newTabBar as well.

umm have a disabled flag and when you process your event for the button tap, if it’s disabled, just return?

So the tabbar doesn’t use sprites (at least not like other buttons) so I am using:

            defaultFile = “ModeOff-btn.png”,
            overFile = “ModeOn-btn.png”,
 

on the buttons. Regardless of how I configure handlers, the overFile appears on press of the tabbar button, because there is no way to disable the tabbar button (like other buttons, isEnabled = false).

I can control resulting behavior by wrapping onPress/onRelease in a flag, but that doesn’t help with the inconsistent UI behavior.

I think disabling the button press behavior is not the main challenge. How do we convey to the user that the button is disabled? IMHO, we would need a third button image indicating that this button is disabled for the time being. Not sure if it is possible to change button images dynamically.

We did make the widgets open source.  If you need that feature, feel free to modify the code that we’ve provided to do so.  Also please feel free to goto http://feedback.coronalabs.com and request the feature there and get your other developers to vote it up.  That way it will get on the radar as a feature to add.

I don’t know that you necessarily need a 3rd state, a :setFillColor to gray and disabling the touch would probably be sufficient.

Agreed. I think we can get away with this approach. Also thinking perhaps we don’t want to disable that touch completely but redirect it in the listener. Ie give user some audible clue as to the button being disabled etc.

I took a quick look at the widget code and did not see any easy way to do this. I agree a disabled tab button would be a great thing to have. This almost needs a third button state image provision. Currently we have Unpressed and Pressed state images and to nicely disable a button we would need to change the button image as well right? I would be interested in this option in the widget newTabBar as well.

umm have a disabled flag and when you process your event for the button tap, if it’s disabled, just return?

So the tabbar doesn’t use sprites (at least not like other buttons) so I am using:

            defaultFile = “ModeOff-btn.png”,
            overFile = “ModeOn-btn.png”,
 

on the buttons. Regardless of how I configure handlers, the overFile appears on press of the tabbar button, because there is no way to disable the tabbar button (like other buttons, isEnabled = false).

I can control resulting behavior by wrapping onPress/onRelease in a flag, but that doesn’t help with the inconsistent UI behavior.

I think disabling the button press behavior is not the main challenge. How do we convey to the user that the button is disabled? IMHO, we would need a third button image indicating that this button is disabled for the time being. Not sure if it is possible to change button images dynamically.

We did make the widgets open source.  If you need that feature, feel free to modify the code that we’ve provided to do so.  Also please feel free to goto http://feedback.coronalabs.com and request the feature there and get your other developers to vote it up.  That way it will get on the radar as a feature to add.

I don’t know that you necessarily need a 3rd state, a :setFillColor to gray and disabling the touch would probably be sufficient.

Agreed. I think we can get away with this approach. Also thinking perhaps we don’t want to disable that touch completely but redirect it in the listener. Ie give user some audible clue as to the button being disabled etc.