1 /******************************************************************************* 2 * Copyright 2011 See AUTHORS file. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 ******************************************************************************/ 16 17 package com.badlogic.gdx.tests; 18 19 import com.badlogic.gdx.Gdx; 20 import com.badlogic.gdx.Input.TextInputListener; 21 import com.badlogic.gdx.graphics.GL20; 22 import com.badlogic.gdx.graphics.g2d.BitmapFont; 23 import com.badlogic.gdx.graphics.g2d.SpriteBatch; 24 import com.badlogic.gdx.tests.utils.GdxTest; 25 26 public class TextInputDialogTest extends GdxTest { 27 String message; 28 SpriteBatch batch; 29 BitmapFont font; 30 create()31 public void create () { 32 message = "Touch screen for dialog"; 33 batch = new SpriteBatch(); 34 font = new BitmapFont(); 35 36 Gdx.input.getTextInput(new TextInputListener() { 37 @Override 38 public void input (String text) { 39 message = "message: " + text + ", touch screen for new dialog"; 40 } 41 42 @Override 43 public void canceled () { 44 message = "cancled by user"; 45 } 46 }, "enter something funny", "funny", "something funny"); 47 } 48 render()49 public void render () { 50 Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 51 batch.begin(); 52 font.draw(batch, message, 10, 40); 53 batch.end(); 54 55 if (Gdx.input.justTouched()) { 56 57 } 58 } 59 } 60