Here is the solution that worked for me. I implement the desired behaviour as a style and not as commands to new buttons.
Attributes attrs = style.getSelector("button", "mystyle");
// the "moving" of the button
Command<Button> pressedCommand = new Command<Button>() {
public void execute( Button source ) {
if( source.isPressed() ) {
source.move(1, -1, 0);
} else {
source.move(-1, 1, 0);
}
}
};
// list of commands + we add the example command
List<Command<Button>> commandlist = new ArrayList<>();
commandlist.add(pressedCommand);
// Map of Buttonactions and commands, we add it for "button clicked/unclicked"
Map<Button.ButtonAction,List<Command<Button>>> commandMap = new HashMap<>();
commandMap.put(Button.ButtonAction.Down,commandlist);
commandMap.put(Button.ButtonAction.Up,commandlist);
// finally we add it to the style
attrs.set("buttonCommands",commandMap);