Search in sources :

Example 26 with TextArea

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

the class IOSImplementation method updateNativeTextEditorFrame.

private static void updateNativeTextEditorFrame(boolean requestFocus) {
    if (instance.currentEditing != null) {
        TextArea cmp = instance.currentEditing;
        Form form = cmp.getComponentForm();
        if (form == null || form != CN.getCurrentForm()) {
            instance.stopTextEditing();
            return;
        }
        int x = cmp.getAbsoluteX() + cmp.getScrollX();
        int y = cmp.getAbsoluteY() + cmp.getScrollY();
        int w = cmp.getWidth();
        int h = cmp.getHeight();
        String key = LAST_UPDATED_EDITOR_BOUNDS_KEY;
        Rectangle lastUpdatedBounds = (Rectangle) cmp.getClientProperty(key);
        if (lastUpdatedBounds != null) {
            if (lastUpdatedBounds.getX() == x && lastUpdatedBounds.getY() == y && lastUpdatedBounds.getWidth() == w && lastUpdatedBounds.getHeight() == h) {
                return;
            }
            lastUpdatedBounds.setBounds(x, y, w, h);
        } else {
            lastUpdatedBounds = new Rectangle(x, y, w, h);
            cmp.putClientProperty(key, lastUpdatedBounds);
        }
        final Style stl = cmp.getStyle();
        final boolean rtl = UIManager.getInstance().getLookAndFeel().isRTL();
        if (requestFocus) {
            instance.doNotHideTextEditorSemaphore++;
            try {
                instance.currentEditing.requestFocus();
            } finally {
                instance.doNotHideTextEditorSemaphore--;
            }
        }
        x = cmp.getAbsoluteX() + cmp.getScrollX();
        y = cmp.getAbsoluteY() + cmp.getScrollY();
        w = cmp.getWidth();
        h = cmp.getHeight();
        int pt = stl.getPaddingTop();
        int pb = stl.getPaddingBottom();
        int pl = stl.getPaddingLeft(rtl);
        int pr = stl.getPaddingRight(rtl);
        /*
            if(cmp.isSingleLineTextArea()) {
                switch(cmp.getVerticalAlignment()) {
                    case TextArea.CENTER:
                        if(h > cmp.getPreferredH()) {
                            y += (h / 2 - cmp.getPreferredH() / 2);
                        }
                        break;
                    case TextArea.BOTTOM:
                        if(h > cmp.getPreferredH()) {
                            y += (h - cmp.getPreferredH());
                        }
                        break;
                }
            }
            */
        Container contentPane = form.getContentPane();
        if (!contentPane.contains(cmp)) {
            contentPane = form;
        }
        Style contentPaneStyle = contentPane.getStyle();
        int minY = contentPane.getAbsoluteY() + contentPane.getScrollY() + contentPaneStyle.getPaddingTop();
        int maxH = Display.getInstance().getDisplayHeight() - minY - nativeInstance.getVKBHeight();
        if (y < minY) {
            h -= (minY - y);
            y = minY;
        }
        if (h > maxH) {
            // For text areas, we don't want the keyboard to cover part of the
            // typing region.  So we will try to size the component to
            // to only go up to the top edge of the keyboard
            // that should allow the OS to enable scrolling properly.... at least
            // in theory.
            h = maxH;
        }
        if (h < 0) {
            // There isn't room for the editor at all.
            Log.p("No room for text editor.  h=" + h);
            instance.stopTextEditing();
            return;
        }
        if (x < 0 || y < 0 || w <= 0 || h <= 0) {
            instance.stopTextEditing();
            return;
        }
        nativeInstance.resizeNativeTextView(x, y, w, h, pt, pr, pb, pl);
    }
}
Also used : Container(com.codename1.ui.Container) TextArea(com.codename1.ui.TextArea) Form(com.codename1.ui.Form) Rectangle(com.codename1.ui.geom.Rectangle) Style(com.codename1.ui.plaf.Style)

Example 27 with TextArea

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

the class BooleanContainer method editNextTextArea.

/**
 * Opens onscreenkeyboard for the next textfield. The method works in EDT if
 * needed.
 */
public static void editNextTextArea() {
    Runnable task = new Runnable() {

        public void run() {
            Component next = getNextEditComponent();
            if (next != null) {
                if (!(next instanceof TextArea)) {
                    IOSImplementation.foldKeyboard();
                }
                next.requestFocus();
                next.startEditingAsync();
            } else {
                IOSImplementation.foldKeyboard();
            }
        }
    };
    Display.getInstance().callSerially(task);
}
Also used : TextArea(com.codename1.ui.TextArea) Component(com.codename1.ui.Component)

Example 28 with TextArea

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

the class DefaultCrashReporter method exception.

/**
 * {@inheritDoc}
 */
public void exception(Throwable t) {
    Preferences.set("$CN1_pendingCrash", true);
    if (promptUser) {
        Dialog error = new Dialog("Error");
        error.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
        TextArea txt = new TextArea(errorText);
        txt.setEditable(false);
        txt.setUIID("DialogBody");
        error.addComponent(txt);
        CheckBox cb = new CheckBox(checkboxText);
        cb.setUIID("DialogBody");
        error.addComponent(cb);
        Container grid = new Container(new GridLayout(1, 2));
        error.addComponent(grid);
        Command ok = new Command(sendButtonText);
        Command dont = new Command(dontSendButtonText);
        Button send = new Button(ok);
        Button dontSend = new Button(dont);
        grid.addComponent(send);
        grid.addComponent(dontSend);
        Command result = error.showPacked(BorderLayout.CENTER, true);
        if (result == dont) {
            if (cb.isSelected()) {
                Preferences.set("$CN1_crashBlocked", true);
            }
            Preferences.set("$CN1_pendingCrash", false);
            return;
        } else {
            if (cb.isSelected()) {
                Preferences.set("$CN1_prompt", false);
            }
        }
    }
    Log.sendLog();
    Preferences.set("$CN1_pendingCrash", false);
}
Also used : Container(com.codename1.ui.Container) GridLayout(com.codename1.ui.layouts.GridLayout) TextArea(com.codename1.ui.TextArea) Command(com.codename1.ui.Command) Button(com.codename1.ui.Button) Dialog(com.codename1.ui.Dialog) CheckBox(com.codename1.ui.CheckBox) BoxLayout(com.codename1.ui.layouts.BoxLayout)

Example 29 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 path the path to the text area
 * @param text the text of the label
 */
public static void assertTextArea(int[] path, String text) {
    if (verbose) {
        log("assertTextArea(" + toString(path) + ", " + text + ")");
    }
    TextArea l = (TextArea) getComponentByPath(path);
    assertBool(l != null, "Null area " + text);
    assertBool(l.getText().equals(text), "assertTextArea: " + l.getText() + " != " + text);
}
Also used : TextArea(com.codename1.ui.TextArea)

Example 30 with TextArea

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

the class TestUtils method setText.

/**
 * Sets the text for the given component
 * @param name the name of the component
 * @param text the text to set
 */
public static void setText(String name, String text) {
    if (verbose) {
        log("setText(" + name + ", " + text + ")");
    }
    Component c = findByName(name);
    if (c instanceof Label) {
        ((Label) c).setText(text);
        return;
    }
    ((TextArea) c).setText(text);
    Display.getInstance().onEditingComplete(c, text);
}
Also used : TextArea(com.codename1.ui.TextArea) Label(com.codename1.ui.Label) Component(com.codename1.ui.Component)

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