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);
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations