Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.TextButton#setChecked()

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.TextButton#setChecked() . 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: GLTFDemoUI.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
private void addMaterialTextureSwitch(String name, final Material material, long type){
	final PBRTextureAttribute attribute = material.get(PBRTextureAttribute.class, type);
	if(attribute != null){
		final TextButton bt = new TextButton(name, getSkin(), "toggle");
		bt.setChecked(true);
		materialTable.add(bt);
		
		Image pict = new Image(attribute.textureDescription.texture);
		
		pict.setScaling(Scaling.fit);
		
		materialTable.add(pict).size(64);
		
		materialTable.row();
		
		bt.addListener(new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {
				if(bt.isChecked()){
					material.set(attribute);
				}else{
					material.remove(attribute.type);
				}
			}
		});
	}
	
}
 
Example 2
Source File: CollapsableUI.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
public CollapsableUI(Skin skin, String name, boolean visible) {
	toggle = new TextButton(name, skin, "toggle");
	toggle.setChecked(visible);
	add(toggle).row();
	optTable = new Table(skin);
	optCell = add();
	row();
	show(visible);
	toggle.addListener(new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			show(toggle.isChecked());
		}
	});
}
 
Example 3
Source File: GLTFDemoUI.java    From gdx-gltf with Apache License 2.0 4 votes vote down vote up
protected TextButton toggle(String name, boolean checked) {
	TextButton bt = new TextButton(name, getSkin(), "toggle");
	bt.setChecked(checked);
	return bt;
}
 
Example 4
Source File: BooleanUI.java    From gdx-gltf with Apache License 2.0 4 votes vote down vote up
public BooleanUI(Skin skin, boolean defaultValue) {
	super(skin);
	bt = new TextButton("enabled", skin, "toggle");
	bt.setChecked(defaultValue);
	add(bt);
}
 
Example 5
Source File: ScopePanel.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
public void changeScope(TextButton b) {		
	b.setChecked(true);
	
	scopeChanged(b.getText().toString());
}
 
Example 6
Source File: MessageTimerTest.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
@Override
public void create () {
	super.create();

	MessageManager.getInstance().clear();

	msgCounter = -1;

	testTable.add(new IntValueLabel("Message Counter: ", 0, container.skin) {
		@Override
		public int getValue () {
			return msgCounter;
		}
	}).left();

	testTable.row();
	testTable.add(new FloatValueLabel("Message Timestamp: ", 0, container.skin) {
		@Override
		public float getValue () {
			return msgTimestamp;
		}
	}).left();

	testTable.row();
	testTable.add(new FloatValueLabel("AI Time: ", 0, container.skin) {
		@Override
		public float getValue () {
			return GdxAI.getTimepiece().getTime();
		}
	}).left();

	testTable.row();
	timerEnabledButton = new TextButton("Stop timer", container.skin);
	timerEnabledButton.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			if (timerEnabledButton.isChecked()) {
				timerEnabledButton.setText("Stop Timer");
				sendMessage(0f, msgCounter + 1);
			} else {
				timerEnabledButton.setText("Start Timer");
			}

		}
	});
	testTable.add(timerEnabledButton).left();

	// Triggers the listener above, so sending the 1st message with no delay and counter 0
	timerEnabledButton.setChecked(true);
}