Disabled Buttons still call callbacks when clicked

Button widgets, when disabled, still invoke their callback function when clicked. I had expected that setting Button.disabled to True would prevent the function of the button, as well as changing the appearance. Using the example code below, the message ‘Start button was clicked’ can be seen in the browser console when the (disabled) button is clicked.

from bokeh.models import Button, CustomJS
from bokeh.plotting import show

callback = CustomJS(code="""
var button_disabled = button.get(‘disabled’)
console.log(‘Start Button was pressed.’)
“”")

button_one = Button(label=“Start”, disabled=True, callback=callback)
callback.args[‘button’] = button_one

show(button_one)

``

Is this intended behaviour? I understand that, of course, I could test the value of Button.disabled in my callback function, but I would expect the callback to simply not be invoked if the Button is disabled.

This seems like something to be fixed, please file a GH issue for it so we can track it for a release.

Thanks,

Bryan

···

On Aug 10, 2016, at 6:15 AM, Toby Hodges <[email protected]> wrote:

Button widgets, when disabled, still invoke their callback function when clicked. I had expected that setting Button.disabled to True would prevent the function of the button, as well as changing the appearance. Using the example code below, the message 'Start button was clicked' can be seen in the browser console when the (disabled) button is clicked.

from bokeh.models import Button, CustomJS
from bokeh.plotting import show

callback = CustomJS(code="""
    var button_disabled = button.get('disabled')
    console.log('Start Button was pressed.')
""")

button_one = Button(label="Start", disabled=True, callback=callback)
callback.args['button'] = button_one

show(button_one)

Is this intended behaviour? I understand that, of course, I could test the value of Button.disabled in my callback function, but I would expect the callback to simply not be invoked if the Button is disabled.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/c9b23594-6fbb-4515-8ffd-75def664e9cc%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.