Can a CustomAction be initialized as active?

Plot tools have this blue line on their left side to indicate they’re active.
I was wondering if there’s a way to initialize a CustomAction so it will have the bk-active class and display this blue line. I tried using the css_classes property but apparently CustomAction doesn’t have it.

Actions do not have any notion of “active”. They are buttons that can be clicked, and when they are clicked an action happens. There is no persistent state associated with them at all. If you want or need a tool to reflect some kind of state, then an Action is not what you want.

I think what is being asked is how to make a custom tool active in the toolbar, something along the lines of …

p.toolbar.active_tap = ...

@_jm I meant the CustomAction class.
@Bryan I see…what about the css_classes property? buttons do have it.

I see. Sorry for my confusion.

@roinr Maybe? Actions are intended to be fire-and-forget. It’s definitely 100% against the intended design and purpose of CustomAction for their toolbar buttons to reflect any kind of “active” state whatsoever, so I’m afraid you are more or less on your own trying to make this happen. The proper solution would be to implement a different kind of tool as a custom extension.

@Bryan But it’s not really a state it’s just a class name that I add to my “widget”. The fact that I can use a JS callback to toggle this class name shouldn’t matter.
Anyways, I guess for now I can still make it work if I decide that the initial state is “inactive”. Once the user clicks the action button a JS callback can toggle the “bk-active” class name.
Thanks!