TextField

A TextField is a text component that is editable when it is focused on. It provides the same editing operations as TextBox and follows the same specification to the extent that TextFields can practically be considered TextBoxes that are inserted into a Form. It can have an initial value that is displayed at initialisation. TextFields are always the same width as the Form they are placed in, but the amount of rows they use can be set.

TextField is always focusable.

The TextEditor supports split view input in portrait mode TextEditor.

  • Touch down and release on an editable TextField activates the field for editing.

  • On Series 40 touch and type, by default, touch down and release activates in-line editing.

  • Touch down and release within the selected TextField moves the text cursor to the point of the tap, provided that there is some text on that point. If there is no text and the user taps the empty space of the TextField the cursor moves to the end of the text.

  • On Series 40 touch and type devices, text can be edited by using the physical keypad. On Series 40 full touch and Nokia Asha software platform devices, you can edit the text through the VirtualKeyboard, that becomes visible when the user taps the TextField.

  • If a TextField has multiple commands assigned to it, touch down and hold on the TextField opens a pop-up menu containing the commands. The pop-up menu corresponds to the context-specific Option's menu of non-touch devices.

TextFields are meant for single line text input and do not support a scrollbar.

Split View versus full screen mode

If you tap a text editor UI element on a touch device with no physical keypad, the virtual keyboard opens. Depending on the device and UI element, the virtual keyboard can open either in split view mode, where the screen is split between the UI element and the virtual keyboard, or in full screen mode, where the virtual keyboard fills most of the screen and the header is removed.

Figure: A TextField example full screen mode

Figure: A TextField example Split view

import javax.microedition.midlet.*; import javax.microedition.lcdui.*;

public class ExampleMIDlet 

   extends MIDlet 
   implements CommandListener {
    
   private Display display;
   private Form form;
   private Command exit;
   private TextField field;
    
   public ExampleMIDlet() {
       form = new Form("Form example 6");
       field = new TextField("Please input a value", "", 16, TextField.ANY);
       form.append(field);
       exit = new Command("Exit", Command.EXIT, 1);
       form.addCommand(exit);
       form.setCommandListener(this);    }
 
   public void startApp() {
       display = Display.getDisplay(this);        
       display.setCurrent(form);
   }    
   public void pauseApp() {
    
   }
    
   public void destroyApp(boolean unconditional) {
    
   }
    
   public void commandAction(Command command, Displayable displayable) {
       if (command == exit) {
           destroyApp(false);
           notifyDestroyed();
       }
   }
}