ItemTrackingAction not work by button.setAction?

We created a new button e.g.

Download

, then use

setAction

in

AbstractEditor.init()

to give it a

new ItemTrackingAction()

, but desired auto enable function was not in effect, by which, means if you don’t have item selected then the button is disabled.

Ideally, if we create a new action that extends ItemTrackingAction, then register this action in xml, and assign it to the button, like the standard action does, it should work fine. But I did not test.

trackSelection="true"

in xml.

Work as a magic!

When you create ItemTrackingAction programmatically, you have to specify what component it should track. There is a special constructor for this: ItemTrackingAction(ListComponent target, String id).