Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.Button#addListener()

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.Button#addListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SignInWindow.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
@Override protected void doShow(String signInReasonKey) {
    Table content = new Table(Config.skin);
    content.setBackground("ui-store-window-background");
    content.defaults().pad(4);

    LocLabel label = new LocLabel(signInReasonKey);
    label.setWrap(true);
    label.setAlignment(Align.center);

    Button button = new Button(Config.skin);
    button.defaults().pad(2);
    button.add(new LocLabel("ui-sign-in")).padTop(1).padLeft(4).expand().right();
    button.add(new Tile("ui/button/services-icon")).padTop(4).padBottom(2).padRight(4).expand().left();
    button.addListener(new ChangeListener() {
        @Override public void changed(ChangeEvent event, Actor actor) {
            signIn = true;
            hide();
        }
    });

    content.add(label).width(130).row();
    content.add(button).width(70).padBottom(8);

    table.add(content);
}
 
Example 2
Source File: TabPanel.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
public void addTab(String name, Actor panel) {
	Button button = new TextButton(name, skin);
	buttonGroup.add(button);
	header.addActor(button);
	tabs.add(new Tab(button, panel));
	
	button.addListener(new ClickListener() {
		
		@Override
		public void clicked (InputEvent event, float x, float y) {
			setTab((Button)event.getListenerActor());
		}
	});
	
	if(tabs.size() == 1)
		setTab(0);
}
 
Example 3
Source File: ProcessingNodeListViewItem.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
public void showLogWindow() {
        final String log = node.getLog();
        if (Strings.isEmpty(log)) return;

        VisDialog dialog = (VisDialog)App.inst().getInterfaceService().getParser().parseTemplate(Gdx.files.internal("lml/dialogPackingLog.lml")).first();
        Container containerLog = dialog.findActor("containerLog");
        final VisScrollPane scrLog = dialog.findActor("scrLog");
        final Button btnCopyToClipboard = dialog.findActor("btnCopyToClipboard");

        VisLabel lblLog = new VisLabel("", "small") {
//            @Override
//            protected void sizeChanged() {
//                super.sizeChanged();
//                // Scroll down scroller
//                scrLog.setScrollPercentY(1f);
//            }
        };
        lblLog.setAlignment(Align.topLeft);
        lblLog.setWrap(true);
        lblLog.setText(log);
        containerLog.setActor(lblLog);

        btnCopyToClipboard.addListener(new ChangeListener() {
            @Override
            public void changed(ChangeEvent event, Actor actor) {
                Gdx.app.getClipboard().setContents(log);
            }
        });

        dialog.getTitleLabel().setText(App.inst().getI18n().format("dialogTitlePackLog", node.getPack().getName()));
        dialog.show(getStage());
        getStage().setScrollFocus(scrLog);
    }
 
Example 4
Source File: ButtonBar.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
public void setButton (ButtonType type, Button button, ChangeListener listener) {
	if (type == null) throw new IllegalArgumentException("type can't be null");
	if (button == null) throw new IllegalArgumentException("button can't be null");
	if (buttons.containsKey(type.id)) buttons.remove(type.id);
	buttons.put(type.id, button);
	if (listener != null) button.addListener(listener);
}
 
Example 5
Source File: LoadSaveScreen.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a button to represent one slot
 *
 * @param slot
 * @return The button to use for one slot
 */
private Button getSlotButton(String slot) {
	final Skin skin = ui.getSkin();
	final Button button = new Button(new ButtonStyle());
	final ButtonStyle style = button.getStyle();
	style.up = style.down = skin.getDrawable("black");

	String textLabel = ui.getWorld().getI18N().getString("ui.newSlot");
	button.setSize(slotWidth, slotHeight);

	if (slotExists(slot)) {
		button.add(getScreenshot(slot)).maxSize(slotWidth * .95f, slotHeight * .95f);

		try {
			long l = Long.parseLong(slot);

			Date d = new Date(l);
			textLabel = (new SimpleDateFormat()).format(d);
		} catch (Exception e) {
			textLabel = slot;
		}

		button.addListener(loadClickListener);
	} else {
		Image fg = new Image(skin.getDrawable("plus"));
		button.add(fg).maxSize(slotHeight / 2, slotHeight / 2);

		button.addListener(saveClickListener);
	}

	button.row();

	Label label = new Label(textLabel, skin);
	label.setAlignment(Align.center);

	button.add(label).fillX();

	button.setName(slot);
	return button;
}
 
Example 6
Source File: SimpleFormValidator.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
/** Validates if given button (usually checkbox) is checked. Use VisCheckBox to additionally support error border around it. */
public void checked (Button button, String errorMsg) {
	buttons.add(new CheckedButtonWrapper(button, true, errorMsg));
	button.addListener(changeListener);
	validate();
}
 
Example 7
Source File: SimpleFormValidator.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
/** Validates if given button (usually checkbox) is unchecked. Use VisCheckBox to additionally support error border around it. */
public void unchecked (Button button, String errorMsg) {
	buttons.add(new CheckedButtonWrapper(button, false, errorMsg));
	button.addListener(changeListener);
	validate();
}