Skip to content

ButtonBar

Paweł Pastuszak edited this page Jun 26, 2016 · 7 revisions

This article applies to VisUI 1.0.0

ButtonBar (source) is a convenient class for creating button panels with buttons such as "Ok", "Cancel", "Yes" etc. Buttons are arranged in platform dependent order which increases UX. Built-in orders support Windows, Mac, and Linux. Linux order is used as default.

How ButtonBar looks on different operating systems:

Simple example ButtonBar:

ButtonBar buttonBar = new ButtonBar(); //no order specified so platform default will be used

ChangeListener dummyListener = new ChangeListener() {
	@Override
	public void changed (ChangeEvent event, Actor actor) {

	}
};

buttonBar.setButton(ButtonType.NO, dummyListener);
buttonBar.setButton(ButtonType.YES, dummyListener);
buttonBar.setButton(ButtonType.CANCEL, dummyListener);

table.add(buttonBar.createTable());

Each ButtonBar can only create one table however it can be reused after previously created table is removed from it's parent.

You can also pass existing instance of buttons:

VisTextButton btn = new VisTextButton("Custom OK Button Text");
buttonBar.setButton(ButtonType.OK, btn);

Buttons order

Buttons order is specified by string of button ids in which order they should be arranged, for example: L H BEF YNOCA R. Each letter represents single button (see ButtonType for buttons ids) and space char is blank space between buttons.

You can set ButtonBar to ignore spacings specified in buttons order:

buttonBar.setIgnoreSpacing(true);