์ด์ ์ฒด์ : Windows 8.1, x64
gdx๋ฒ์ : 1.2.0
ํ๊ฒํ
: ๋ฐ์คํฌํฑ ์ ์ฉ(๋ค๋ฅธ ํ๋ซํผ์์๋ ํ
์คํธ๋์ง ์์)
SelectBox๋ฅผ ํด๋ฆญํ์ฌ ๋๋กญ๋ค์ด ๋ชฉ๋ก์ ํ์ํ ๋; ์ธ์ ํ ํ ์ด๋ธ ์ ์ TextField๋ ํฌ์ปค์ค๋ฅผ ์์ด์ผ ํ์ง๋ง ๊ทธ๋ ์ง ์์ต๋๋ค. ์ด๋ฌํ ๊ตฌ์ฑ ์์๋ ํ ์ด๋ธ๊ณผ ์คํ ์ด์ง๋ฅผ ๊ณต์ ํฉ๋๋ค. ์ํธ ๋จ๊ณ๋ ์ ๋ ฅ์ ์ฒ๋ฆฌํฉ๋๋ค.
์ด๊ฒ์ ์ค์ ๋ก ์๋ฌด ๊ฒ๋ ์์์ํค์ง ์์ง๋ง ๋ฐ๋์งํ์ง ์์ ๋์์ด๋ฉฐ ๊ฒ์์ ๋น์ ๋ฌธ์ ์ผ๋ก ๋ณด์ด๊ฒ ๋ง๋ค ์ ์์ต๋๋ค.
์ฌํํ ๊ด๋ จ ์ฝ๋:
import com.badlogic.gdx.scenes.scene2d.ui.*;
final Label titleLabel = new Label(
"Title: ", skin, "heading");
final Label typeLabel = new Label(
"Type: ", skin, "heading");
final TextField textField = new TextField("", skin);
final SelectBox<String> contextSelector = new SelectBox<String>(skin);
contextSelector.setItems("Weapon", "Tool", "Crop", "Machine", "World Rule");
table.row();
table.add(titleLabel).right();
table.add(textField).fill().prefWidth(Gdx.graphics.getWidth() / 5.0f).space(1.0f);
table.row();
table.add(typeLabel).right();
table.add(contextSelector).fill().prefWidth(Gdx.graphics.getWidth() / 5.0f).space(1.0f);
table.row().height(15.0f); table.add().fill();
table.row();
table.add(placeHolderLabel1);
table.add(startButton).right();
๋ค๋ฅธ ์กํฐ๋ฅผ ํด๋ฆญํ ๋ TextField๊ฐ ํญ์ ํฌ์ปค์ค๋ฅผ ์๊ธฐ๋ฅผ ์ํ๋์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ๋์์ ์ง์ ์ฌ์ฉ์ ์ ์ํ ์ ์์ต๋๋ค.
stage.getRoot().addCaptureListener(new InputListener() {
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
if (!(event.getTarget() instanceof TextField)) stage.setKeyboardFocus(null);
return false;
}
}
๊ธ์, ๊ทธ๊ฒ์ ํ์คํ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํฉ๋๋ค. ๊ฑด๋ฐฐ. :-)
๋ค์ ํ ๋ฒ ๋ด ๋ฌธ์ ์ ๋ํ ์ฐ์ํ ์๋ฃจ์ ์ ์ฐพ์์ต๋๋ค. scene2d๋ ๊ต์ฅํฉ๋๋ค :)
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋ค๋ฅธ ์กํฐ๋ฅผ ํด๋ฆญํ ๋ TextField๊ฐ ํญ์ ํฌ์ปค์ค๋ฅผ ์๊ธฐ๋ฅผ ์ํ๋์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ๋์์ ์ง์ ์ฌ์ฉ์ ์ ์ํ ์ ์์ต๋๋ค.