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