Search in sources :

Example 31 with TextArea

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

the class TestUtils method assertTextArea.

/**
 * Asserts that we have a label with the given text baring the given name
 * @param text the text of the label
 */
public static void assertTextArea(String text) {
    if (verbose) {
        log("assertTextArea(" + text + ")");
    }
    TextArea l = findTextAreaText(text);
    assertBool(l != null, "Null text " + text);
}
Also used : TextArea(com.codename1.ui.TextArea)

Example 32 with TextArea

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

the class AndroidKeyboard method showKeyboard.

public void showKeyboard(boolean show) {
    // manager.restartInput(myView);
    // if (keyboardShowing != show) {
    // manager.toggleSoftInputFromWindow(myView.getWindowToken(), 0, 0);
    // this.keyboardShowing = show;
    // }
    System.out.println("showKeyboard " + show);
    Form current = Display.getInstance().getCurrent();
    if (current != null) {
        Component cmp = current.getFocused();
        if (cmp != null && cmp instanceof TextArea) {
            TextArea txt = (TextArea) cmp;
            if (show) {
                Display.getInstance().editString(txt, txt.getMaxSize(), txt.getConstraint(), txt.getText(), 0);
            }
        }
    } else {
        InPlaceEditView.endEdit();
    }
// if(!show){
// impl.saveTextEditingState();
// }
}
Also used : Form(com.codename1.ui.Form) TextArea(com.codename1.ui.TextArea) Component(com.codename1.ui.Component)

Example 33 with TextArea

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

the class BlackBerryCanvas method paint.

public void paint(Graphics g) {
    int f = getFieldCount();
    if (f > 0) {
        g.drawBitmap(0, 0, getWidth(), getHeight(), screen, 0, 0);
        Form currentForm = Display.getInstance().getCurrent();
        for (int iter = 0; iter < f; iter++) {
            Field fld = getField(iter);
            int pops = 0;
            if (currentForm != null) {
                PeerComponent p = findPeer(currentForm.getContentPane(), fld);
                if (p != null) {
                    pops = clipOnLWUITBounds(p, g);
                } else {
                    Component cmp = currentForm.getFocused();
                    // we are now editing an edit field
                    if (cmp != null && cmp instanceof TextArea && cmp.hasFocus() && fld instanceof EditField) {
                        pops = clipOnLWUITBounds(cmp, g);
                        int x = fld.getLeft();
                        int y = fld.getTop();
                        g.clear(x, y, Math.max(cmp.getWidth(), fld.getWidth()), Math.max(cmp.getHeight(), fld.getHeight()));
                    }
                }
            }
            paintChild(g, fld);
            while (pops > 0) {
                g.popContext();
                pops--;
            }
        }
    } else {
        g.drawBitmap(0, 0, getWidth(), getHeight(), screen, 0, 0);
    }
    g.setColor(0);
    g.drawText(debug, 0, 0);
    painted = true;
}
Also used : EditField(net.rim.device.api.ui.component.EditField) Field(net.rim.device.api.ui.Field) PeerComponent(com.codename1.ui.PeerComponent) EditField(net.rim.device.api.ui.component.EditField) Form(com.codename1.ui.Form) TextArea(com.codename1.ui.TextArea) Component(com.codename1.ui.Component) PeerComponent(com.codename1.ui.PeerComponent)

Example 34 with TextArea

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

the class ResetableTextWatcher method onTouchEvent.

/*
    static void handleActiveTouchEventIfHidden(MotionEvent event) {
        if (sInstance != null && mIsEditing && isActiveTextEditorHidden()) {
            sInstance.onTouchEvent(event);
        }
    }
    */
@Override
public boolean onTouchEvent(MotionEvent event) {
    if (!impl.isAsyncEditMode()) {
        boolean leaveVKBOpen = false;
        if (mEditText != null && mEditText.mTextArea != null && mEditText.mTextArea.getComponentForm() != null) {
            Component c = mEditText.mTextArea.getComponentForm().getResponderAt((int) event.getX(), (int) event.getY());
            if (mEditText.mTextArea.getClientProperty("leaveVKBOpen") != null || (c != null && c instanceof TextArea && ((TextArea) c).isEditable() && ((TextArea) c).isEnabled())) {
                leaveVKBOpen = true;
            }
        }
        // When the user touches the screen outside the text-area, finish editing
        endEditing(REASON_TOUCH_OUTSIDE, leaveVKBOpen, 0);
    } else {
        final int evtX = (int) event.getX();
        final int evtY = (int) event.getY();
        Display.getInstance().callSerially(new Runnable() {

            public void run() {
                if (mEditText != null && mEditText.mTextArea != null) {
                    TextArea tx = mEditText.mTextArea;
                    int x = tx.getAbsoluteX() + tx.getScrollX();
                    int y = tx.getAbsoluteY() + tx.getScrollY();
                    int w = tx.getWidth();
                    int h = tx.getHeight();
                    if (!(x <= evtX && y <= evtY && x + w >= evtX && y + h >= evtY)) {
                        hideTextEditor();
                    } else {
                        showTextEditorAgain();
                    }
                }
            }
        });
    }
    // We don't want to consume this event
    return false;
}
Also used : TextArea(com.codename1.ui.TextArea) Component(com.codename1.ui.Component) Paint(android.graphics.Paint)

Example 35 with TextArea

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

the class ResetableTextWatcher method hideTextEditor.

/**
 * Hides the native text editor while keeping the active async edit session going.
 * This will effectively hide the native text editor, and show the light-weight text area
 * with cursor still in the correct position.
 */
private void hideTextEditor() {
    if (!mIsEditing || textEditorHidden || mEditText == null) {
        return;
    }
    textEditorHidden = true;
    final TextArea ta = mEditText.mTextArea;
    // Since this may be called off the UI thread, we need to issue async request on UI thread
    // to hide the text area.
    impl.getActivity().runOnUiThread(new Runnable() {

        public void run() {
            if (mEditText != null && mEditText.mTextArea == ta) {
                // Note:  Setting visibility to GONE doesn't work here because the TextWatcher
                // will stop receiving input from the keyboard, so we don't have a way to
                // reactivate the text editor when the user starts typing again.  Using the margin
                // to move it off screen keeps the text editor active.
                mEditLayoutParams.setMargins(-Display.getInstance().getDisplayWidth(), 0, 0, 0);
                InPlaceEditView.this.requestLayout();
                final int cursorPos = mEditText.getSelectionStart();
                // Since we are going to be displaying the CN1 text area now, we need to update
                // the cursor.  That needs to happen on the EDT.
                Display.getInstance().callSerially(new Runnable() {

                    public void run() {
                        if (mEditText != null && mEditText.mTextArea == ta && mIsEditing && textEditorHidden) {
                            if (ta instanceof TextField) {
                                ((TextField) ta).setCursorPosition(cursorPos);
                            }
                        }
                    }
                });
            }
        }
    });
    // Repaint the CN1 text area on the EDT.  This is necessary because while the native editor
    // was shown, the cn1 text area paints only its background.  Now that the editor is hidden
    // it should paint its foreground also.
    Display.getInstance().callSerially(new Runnable() {

        public void run() {
            if (mEditText != null && mEditText.mTextArea != null) {
                mEditText.mTextArea.repaint();
            }
        }
    });
// repaintTextEditor(true);
}
Also used : TextArea(com.codename1.ui.TextArea) TextField(com.codename1.ui.TextField)

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