Search in sources :

Example 56 with TextArea

use of com.vaadin.v7.ui.TextArea in project CodenameOne by codenameone.

the class BlackBerryVirtualKeyboard method showKeyboard.

public void showKeyboard(boolean show) {
    // we need this since when opening the VKB the text field loses focus and tries to fold the keyboard for some reason
    if (blockFolding && !show) {
        return;
    }
    if (canvas.getVirtualKeyboard() == null) {
        return;
    }
    if (show) {
        if (isVirtualKeyboardShowing()) {
            return;
        }
        canvas.getVirtualKeyboard().setVisibility(VirtualKeyboard.SHOW);
        Form current = canvas.getImplementation().getCurrentForm();
        Component focus = current.getFocused();
        if (focus != null && focus instanceof TextArea) {
            TextArea txtCmp = (TextArea) focus;
            if ((txtCmp.getConstraint() & TextArea.NON_PREDICTIVE) == 0) {
                canvas.getImplementation().editString(txtCmp, txtCmp.getMaxSize(), txtCmp.getConstraint(), txtCmp.getText(), 0);
            }
        }
    } else {
        canvas.getVirtualKeyboard().setVisibility(VirtualKeyboard.HIDE);
        canvas.getImplementation().finishEdit(true);
    }
}
Also used : Form(com.codename1.ui.Form) TextArea(com.codename1.ui.TextArea) Component(com.codename1.ui.Component)

Example 57 with TextArea

use of com.vaadin.v7.ui.TextArea in project CodenameOne by codenameone.

the class HTMLComponent method setInputFormat.

/**
 * Sets input format validation for a TextArea or TextField
 * This is called from the CSSEngine, and since it is done after the TextArea has been added it is a bit more complicated
 *
 * @param inputField The TextArea to place the input format validation on
 * @param inputFormat The string representing the input format
 * @return The same TextArea or a new instance representing the element
 */
TextArea setInputFormat(final TextArea inputField, String inputFormat) {
    TextArea returnInputField = inputField;
    if (SUPPORT_INPUT_FORMAT) {
        HTMLForm form = (HTMLForm) textfieldsToForms.get(inputField);
        if (form != null) {
            HTMLInputFormat format = HTMLInputFormat.getInputFormat(inputFormat);
            if (format != null) {
                form.setInputFormat(inputField, format);
                final TextArea newInputField = format.applyConstraints(inputField);
                returnInputField = newInputField;
                // Replace operation must be done on the EDT if the form is visible
                if (Display.getInstance().getCurrent() != inputField.getComponentForm()) {
                    // ((inputField.getComponentForm()==null) ||
                    // Applying the constraints may return a new instance that has to be replaced in the form
                    inputField.getParent().replace(inputField, newInputField, null);
                } else {
                    Display.getInstance().callSerially(new Runnable() {

                        public void run() {
                            // Applying the constraints may return a new instance that has to be replaced in the form
                            inputField.getParent().replace(inputField, newInputField, null);
                        }
                    });
                }
                if (firstFocusable == inputField) {
                    firstFocusable = newInputField;
                }
            }
        }
    }
    return returnInputField;
}
Also used : TextArea(com.codename1.ui.TextArea)

Example 58 with TextArea

use of com.vaadin.v7.ui.TextArea in project CodenameOne by codenameone.

the class HTMLForm method reset.

/**
 * Called when a form reset is needed and resets all the form fields to their default values.
 */
void reset() {
    for (Enumeration e = defaultValues.keys(); e.hasMoreElements(); ) {
        Object input = e.nextElement();
        if (input instanceof TextArea) {
            // catches both textareas and text input fields
            String defVal = (String) defaultValues.get(input);
            if (defVal == null) {
                defVal = "";
            }
            ((TextArea) input).setText(defVal);
        } else if (input instanceof ComboBox) {
            OptionItem defVal = (OptionItem) defaultValues.get(input);
            ComboBox combo = ((ComboBox) input);
            if (defVal != null) {
                combo.setSelectedItem(defVal);
            } else if (combo.size() > 0) {
                combo.setSelectedIndex(0);
            }
        }
    }
    for (Enumeration e = defaultCheckedButtons.elements(); e.hasMoreElements(); ) {
        Button b = (Button) e.nextElement();
        if (!b.isSelected()) {
            setButton(b, true);
        }
    }
    for (Enumeration e = defaultUncheckedButtons.elements(); e.hasMoreElements(); ) {
        Button b = (Button) e.nextElement();
        if (b.isSelected()) {
            setButton(b, false);
        }
    }
}
Also used : Enumeration(java.util.Enumeration) TextArea(com.codename1.ui.TextArea) RadioButton(com.codename1.ui.RadioButton) Button(com.codename1.ui.Button) ComboBox(com.codename1.ui.ComboBox)

Example 59 with TextArea

use of com.vaadin.v7.ui.TextArea in project CodenameOne by codenameone.

the class CodenameOneView method setInputType.

public void setInputType(EditorInfo editorInfo) {
    /**
     * do not use the enter key to fire some kind of action!
     */
    // editorInfo.imeOptions |= EditorInfo.IME_ACTION_NONE;
    Component txtCmp = Display.getInstance().getCurrent().getFocused();
    if (txtCmp != null && txtCmp instanceof TextArea) {
        TextArea txt = (TextArea) txtCmp;
        if (txt.isSingleLineTextArea()) {
            editorInfo.imeOptions |= EditorInfo.IME_ACTION_DONE;
        } else {
            editorInfo.imeOptions |= EditorInfo.IME_ACTION_NONE;
        }
        int inputType = 0;
        int constraint = txt.getConstraint();
        if ((constraint & TextArea.PASSWORD) == TextArea.PASSWORD) {
            constraint = constraint ^ TextArea.PASSWORD;
        }
        switch(constraint) {
            case TextArea.NUMERIC:
                inputType = EditorInfo.TYPE_CLASS_NUMBER | EditorInfo.TYPE_NUMBER_FLAG_SIGNED;
                break;
            case TextArea.DECIMAL:
                inputType = EditorInfo.TYPE_CLASS_NUMBER | EditorInfo.TYPE_NUMBER_FLAG_DECIMAL;
                break;
            case TextArea.PHONENUMBER:
                inputType = EditorInfo.TYPE_CLASS_PHONE;
                break;
            case TextArea.EMAILADDR:
                inputType = EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
                break;
            case TextArea.URL:
                inputType = EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_URI;
                break;
            default:
                inputType = EditorInfo.TYPE_CLASS_TEXT;
                break;
        }
        editorInfo.inputType = inputType;
    }
}
Also used : TextArea(com.codename1.ui.TextArea) Component(com.codename1.ui.Component) PeerComponent(com.codename1.ui.PeerComponent)

Example 60 with TextArea

use of com.vaadin.v7.ui.TextArea in project CodenameOne by codenameone.

the class ResetableTextWatcher method reLayoutEdit.

public static void reLayoutEdit(boolean force) {
    if (mIsEditing && !isActiveTextEditorHidden() && sInstance != null && sInstance.mEditText != null) {
        final TextArea txt = sInstance.mEditText.mTextArea;
        if (!force && lastTextAreaX == txt.getAbsoluteX() + txt.getScrollX() && lastTextAreaY == txt.getAbsoluteY() + txt.getScrollY() && lastTextAreaWidth == txt.getWidth() && lastTextAreaHeight == txt.getHeight()) {
            return;
        }
        Display.getInstance().callSerially(new Runnable() {

            public void run() {
                if (mIsEditing && !isActiveTextEditorHidden() && sInstance != null && sInstance.mEditText != null) {
                    if (txt != null) {
                        if (sInstance.mEditText.mTextArea != txt) {
                            // has changed in between, skip or would change location back to old field
                            return;
                        }
                        final int txty = lastTextAreaY = txt.getAbsoluteY() + txt.getScrollY();
                        final int txtx = lastTextAreaX = txt.getAbsoluteX() + txt.getScrollX();
                        final int w = lastTextAreaWidth = txt.getWidth();
                        final int h = lastTextAreaHeight = txt.getHeight();
                        sInstance.impl.getActivity().runOnUiThread(new Runnable() {

                            public void run() {
                                if (mIsEditing && !isActiveTextEditorHidden() && sInstance != null && sInstance.mEditText != null) {
                                    if (sInstance.mEditText.mTextArea != txt) {
                                        // has changed in between, skip or would change location back to old field
                                        return;
                                    }
                                    sInstance.mEditLayoutParams.setMargins(txtx, txty, 0, 0);
                                    sInstance.mEditLayoutParams.width = w;
                                    sInstance.mEditLayoutParams.height = h;
                                    if (!txt.isSingleLineTextArea() && txt.getDoneListener() != null) {
                                        sInstance.mEditText.getLayoutParams().width = w;
                                        sInstance.mEditText.getLayoutParams().height = h;
                                        sInstance.mEditText.setMaxWidth(w);
                                        sInstance.mEditText.setMaxHeight(h);
                                        sInstance.setHorizontalScrollBarEnabled(false);
                                        sInstance.mEditText.setHorizontallyScrolling(false);
                                    }
                                    sInstance.mEditText.requestLayout();
                                    sInstance.invalidate();
                                    if (sInstance.getVisibility() != VISIBLE) {
                                        sInstance.setVisibility(VISIBLE);
                                    }
                                    sInstance.bringToFront();
                                }
                            }
                        });
                    }
                }
            }
        });
    }
}
Also used : TextArea(com.codename1.ui.TextArea)

Aggregations

TextArea (com.codename1.ui.TextArea)60 Form (com.codename1.ui.Form)23 Component (com.codename1.ui.Component)21 Button (com.codename1.ui.Button)16 Label (com.codename1.ui.Label)16 TextArea (com.vaadin.v7.ui.TextArea)15 Container (com.codename1.ui.Container)13 BorderLayout (com.codename1.ui.layouts.BorderLayout)12 Label (com.vaadin.ui.Label)11 ComboBox (com.vaadin.v7.ui.ComboBox)10 TextField (com.codename1.ui.TextField)9 DateComparisonValidator (de.symeda.sormas.ui.utils.DateComparisonValidator)9 DateField (com.vaadin.v7.ui.DateField)8 TextField (com.vaadin.v7.ui.TextField)8 NullableOptionGroup (de.symeda.sormas.ui.utils.NullableOptionGroup)7 RadioButton (com.codename1.ui.RadioButton)6 Field (com.vaadin.v7.ui.Field)6 BoxLayout (com.codename1.ui.layouts.BoxLayout)5 Paint (android.graphics.Paint)4 CheckBox (com.codename1.ui.CheckBox)4