Setting the editing style for Form Items

On Series 40 touch devices, by default, when the user taps an editable Form Item, the MIDlet UI activates the item for in-line editing. However, on Series 40 6th Edition FP 1 touch devices, the equivalent native UI components use a pop-up ("substate") window for editing the content.

Figure: TextField being edited in-line (left) and in a pop-up window (right)

In practice, this means that the following Form Items have native UI counterparts on Series 40 6th Edition FP 1 devices that use a pop-up window for editing:

You can switch the editing style for these Form Items by using the LCDUIUtil.setObjectTrait method. If you try to set the editing style for an editable Form Item that does not have a native UI counterpart, such as DateField of type DATE_TIME, the method call is ignored. This feature is supported since Series 40 6th Edition FP 1.

To use a pop-up window for editing:

  1. Import the LCDUIUtil class:

    import com.nokia.mid.ui.LCDUIUtil;
  2. Create the Form Item whose editing style you want to align with the native UI, and set the editing style using the setObjectTrait method:

    // create the Form Item (in this case, a DateField of type DATE)
    DateField dateField = new DateField("Date", DateField.DATE);
    
    // set the editing style to pop-up
    LCDUIUtil.setObjectTrait(dateField, "nokia.ui.s40.item.substate", Boolean.TRUE);

    To set the editing style back to in-line, use the same method call, but set the third parameter to Boolean(false):

    LCDUIUtil.setObjectTrait(dateField, "nokia.ui.s40.item.substate", Boolean.FALSE);

To query the editing style used by a Form Item, use the LCDUIUtil.getObjectTrait method:

// check whether or not a pop-up window is used for editing
Object traitValue = LCDUIUtil.getObjectTrait(dateField, "nokia.ui.s40.item.substate");

// extract the boolean value from the returned Object:
// if true, a pop-up window is used
// if false, in-line editing is used
boolean popupUsed = ((Boolean)traitValue).booleanValue();