Using class EditText with processing?

edited October 2015 in Android Mode

Hello,

I have this looking everywhere for a simple way to write and edit text strings in android.

I tried using the controlP5 library, but does not affect the virtual keyboard keystrokes.

I think what I want can be done with editext, but my code does not work, any ideas?

import android.widget.EditText;
   import android.view.inputmethod.InputMethodManager;
    import android.inputmethodservice.KeyboardView.OnKeyboardActionListener;
    import android.view.KeyEvent;
    import android.view.View;
    import android.util.DisplayMetrics;
    import android.net.wifi.WifiInfo;
    import android.net.wifi.WifiManager;
   import android.content.Context;
   import android.content.pm.ActivityInfo;
   import android.content.SharedPreferences;
   import android.content.SharedPreferences.Editor;

  // EditText myEditText =  (EditText) findViewById(R.id.vnosEmaila);
import controlP5.*;
EditText txt1;
   InputMethodManager imm;
ControlP5 cp5;

String textValue = "";
String textValue2 = "";
void setup() {

 txt1 = (EditText)findViewById(R.id.text);


  size(700,400);

  PFont font = createFont("arial",20);

  cp5 = new ControlP5(this);

  cp5.addTextfield("input")
     .setPosition(20,100)
     .setSize(200,40)
     .setFont(font)
     .setFocus(true)
     .setColor(color(255,0,0))
     ;

  cp5.addTextfield("textValue")
     .setPosition(20,170)
     .setSize(200,40)
     .setFont(createFont("arial",20))
     .setAutoClear(false)
     ;

  cp5.addBang("clear")
     .setPosition(240,170)
     .setSize(80,40)
     .getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER)
     ;    

  cp5.addTextfield("default")
     .setPosition(20,350)
     .setAutoClear(false)
     ;

  textFont(font);
}

void draw() {if(mousePressed == true){showVirtualKeyboard();delay(888);}
  background(0);
  fill(255);
try{textValue2 = txt1.getText().toString();  }catch(Exception e){}
//  if(key != 0){textValue=textValue+key;text(cp5.get(Textfield.class,"input").getText(), 360,130);key = 0;}
  text(textValue2, 360,180);//text(input, 460,180);
}

public void clear() {
  cp5.get(Textfield.class,"textValue").clear();
}

void controlEvent(ControlEvent theEvent) {
  if(theEvent.isAssignableFrom(Textfield.class)) {
    println("controlEvent: accessing a string from controller '"
            +theEvent.getName()+"': "
            +theEvent.getStringValue()
            );
  }
}

  public void showVirtualKeyboard() 
  {
    //LIMPIEZA     teclado_ON = 0; 
              InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
              imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
    //    image(fondo, 0, 0);
  }

public void input(String theText) {
  // automatically receives results from controller input
  println("a textfield event for controller 'input' : "+theText);
}

greetings and thanks in advance

Answers

  • Answer ✓

    @anthony20====

    this line cannot work: txt1 = (EditText)findViewById(R.id.text); if you want to work with that kind of code you have to use eclipse & pure android... simple way for editing text in processing is using apwidgets lib

  • edited February 2015

    Hi @Akenaton, Thanks so much.

    I am testing apwidgets.

    import apwidgets.*;
    
    APWidgetContainer widgetContainer; 
    APEditText textField;
    
    void setup(){
      widgetContainer = new APWidgetContainer(this); //create new container for widgets
      textField = new APEditText(20, 10, 150, 50); //create a textfield from x- and y-pos., width and height
      widgetContainer.addWidget(textField); //place textField in container
      textField.setImeOptions(EditorInfo.IME_ACTION_DONE); //Enables a Done button
      textField.setCloseImeOnDone(true); 
    }
    
    void draw(){
    if(mousePressed == true){showVirtualKeyboard();delay(888);}
      background(0); //black background 
      text(textField.getText(), 10, 10); //display the text in the text field
    }
    
      public void showVirtualKeyboard() 
      {
                  InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                  imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
    
      }
    

    I need to know it: My android app is forced horizontal position. includes a search method through string that is updated every time it receives a keystroke. I use the key variable processing to gradually modify the string. this works great on a samsung galaxy ace and a tablet that I have. However, in a mini samsung galaxy detected only numeric keystrokes. When I try apwidgets I see is great and easier to use than direct control over the key variable. However, when jumping the keyboard in a horizontal position, the app no longer displayed.

    How can you avoid large text box appears?

    greetings and thanks for showing me this great library

  • @anthony20===

    as for beginning try to add orientation(LANDSCAPE) in setup() and in the manifest

  • edited February 2015

    @akenaton thanks for you answer

    I tried that but it does not work. I want that when I click on the box, a normal keyboard appears. like when I use showVirtualKeyboard () i want it: keyboard type:

    The problem is this keyboard that covers the application when it is working horizontal:

    My app is designed on forced landscape mode.

    when I use showVirtualKeyboard () I can not write about EditText box.

    In short, I want the throwing editext in landscape mode, keyboard not cover my app.

    I think this may be due to some library option that launches the keyboard in that mode. I'm trying somehow to deceive the library to report that the phone is vertical.

  • edited February 2015

    I fail, I thought the problem was the horizontallyScrolling variable, but I modified true and false and nothing has changed.

    I found in the library code keyboard close, but not the "showVirtualKeyboard" I need to change.

        InputMethodManager imm = (InputMethodManager)pApplet.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(textView.getWindowToken(), 0);
    
    
    
    
    import android.widget.EditText;
       import android.view.inputmethod.InputMethodManager;
        import android.inputmethodservice.KeyboardView.OnKeyboardActionListener;
        import android.view.KeyEvent;
        import android.view.View;
        import android.util.DisplayMetrics;
        import android.net.wifi.WifiInfo;
        import android.net.wifi.WifiManager;
       import android.content.Context;
       import android.content.pm.ActivityInfo;
       import android.content.SharedPreferences;
       import android.content.SharedPreferences.Editor;
    import android.text.InputType;
    import android.view.inputmethod.EditorInfo;
    
    
    
    //import apwidgets.*;
    
    APWidgetContainer widgetContainer; 
    APEditText textField;
    
    void setup(){
           setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    
      widgetContainer = new APWidgetContainer(this); //create new container for widgets
      textField = new APEditText(20, 10, 150, 50); //create a textfield from x- and y-pos., width and height
      widgetContainer.addWidget(textField); //place textField in container
      textField.setImeOptions(EditorInfo.IME_ACTION_DONE); //Enables a Done button
      textField.setCloseImeOnDone(true); 
    }
    String KEY = "";String KEYC = "";
    void draw(){
        background(0); //black background 
    if(mousePressed == true){showVirtualKeyboard();delay(888);}
    
    if(key != 0){ KEY = KEY + int(key)+ "";key = 0;}else{text("KEY",290,222);}
    text(KEY,29,2882);
    text("      L "+KEY,29,222);
    if(random(100) > 99){  text(textField.getText(), 10, 10);} //display the text in the text field
    
    if(keyCode != 0){KEYC = KEYC + int(keyCode);keyCode = 0;}
    text("      LC "+KEYC,29,122);
    }
    
    
      public void showVirtualKeyboard() 
      {
        //LIMPIEZA     teclado_ON = 0; 
                  InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                  imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
        //    image(fondo, 0, 0);
      }
    
    
    
    import processing.core.PApplet;
    import android.content.Context;
    import android.text.InputType;
    import android.view.KeyEvent;
    import android.view.inputmethod.EditorInfo;
    import android.view.inputmethod.InputMethodManager;
    import android.widget.EditText;
    import android.widget.TextView;
    import android.widget.TextView.OnEditorActionListener;
    
    
    
    public class APEditText extends APTextView implements OnEditorActionListener{
    
      private APEditText nextEditText = null;
      private boolean closeImeOnDone = false;
    
      private int editorInfo = EditorInfo.TYPE_NULL;
      private int getEditorInfo(){
        return editorInfo;
      }
    
      private int inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE;
      private int getInputType(){
        return inputType;
      }
    
      private boolean horizontallyScrolling = true;
      public boolean getHorizontallyScrolling(){
        return horizontallyScrolling;
      }
    
    
      public void setCloseImeOnDone(boolean closeImeOnDone){
        this.closeImeOnDone = closeImeOnDone;
      }
    
    
      public void setNextEditText(APEditText nextEditText){
        if(nextEditText==null){
          throw new NullPointerException("Have you initialized the PEditText used as an argument in calling setNextEditText?");
        }else{
          this.nextEditText = nextEditText;
        }
      }
    
      public APEditText(int x, int y, int width, int height) {
        super(x, y, width, height, "");
        this.shouldNotSetOnClickListener = true; //otherwise ime options done, next etc doesn't work
      }
      /**
       * Initializes the text field. Is called by {@link APWidgetContainer} 
       * as it is added to it.
       * 
       */
      public void init(PApplet pApplet) {
        this.pApplet = pApplet;
    
        if (view == null) {
          view = new EditText(pApplet);
        }
        ((EditText)view).setInputType(inputType);
        ((EditText)view).setImeOptions(editorInfo);
        ((EditText)view).setHorizontallyScrolling(horizontallyScrolling);
        ((EditText)view).setOnEditorActionListener(this);
    
        super.init(pApplet);
      }
      public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent){
        if(actionId == EditorInfo.IME_ACTION_NEXT){
          if(nextEditText != null){
            ((EditText)nextEditText.getView()).requestFocus();
            return true;
          }
        }else if(actionId == EditorInfo.IME_ACTION_DONE){
          onClick(view);
          if(closeImeOnDone){
            InputMethodManager imm = (InputMethodManager)pApplet.getSystemService(Context.INPUT_METHOD_SERVICE);
              imm.hideSoftInputFromWindow(textView.getWindowToken(), 0);
          }
          return true;
        }
        return false;
      }
      /**
       * You can set IMEOptions for this EditText using this method. 
       * See list of IMEOptions here: <a href="http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html">
       * http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html</a>;
       * @param editorInfo
       */
      public void setImeOptions(int editorInfo){
        this.editorInfo = editorInfo;
        if (initialized) {
          pApplet.runOnUiThread(new Runnable() {
            public void run() {
              ((EditText) view).setImeOptions(getEditorInfo());
            }
          });
        }
      }
      /**
       * You can set InputType here. See list of different InputTypes here: 
       * <a href="http://developer.android.com/reference/android/text/InputType.html">
       * http://developer.android.com/reference/android/text/InputType.html</a>;
       * @param inputType
       */
      public void setInputType(int inputType){
        this.inputType = inputType;
        if (initialized) {
          pApplet.runOnUiThread(new Runnable() {
            public void run() {
              ((EditText) view).setInputType(getInputType());
            }
          });
        }
      }
      public void setHorizontallyScrolling(boolean horizontallyScrolling){
        this.horizontallyScrolling = horizontallyScrolling;
        if (initialized) {
          pApplet.runOnUiThread(new Runnable() {
            public void run() {
              ((EditText) view).setHorizontallyScrolling(getHorizontallyScrolling());
            }
          });
        }
      }
    
    }
    
    
    
    
    
    
    
    //________________
    import processing.core.PApplet;
    import android.text.Editable;
    import android.text.TextWatcher;
    import android.widget.TextView;
    
    public abstract class APTextView extends APWidget implements TextWatcher{
    
      private int textSize = -1;
      private String text;
      private int textColor = -1;
    
    
      public APTextView(int x, int y, int width, int height,
          String text) {
        super(x, y, width, height);
        this.text = text;
      }
    
     public String getText() {
      //  if (!initialized) {
          return text;
      //  } else {
      //    long time = System.currentTimeMillis();
      //    while (view == null && System.currentTimeMillis() < time + 1000) {
      //    }
      //    return ((TextView) view).getText().toString();
      //  }
      }
    
      public void setTextSize(int textSize) {
        this.textSize = textSize;
        if (initialized) {
          pApplet.runOnUiThread(new Runnable() {
            public void run() {
              ((TextView) view).setTextSize(getTextSize());
            }
          });
        }
      }
      /**
       * 
       * @param text The text content.
       */
      public void setText(String text) {
        this.text = text;
        if (initialized) {
          pApplet.runOnUiThread(new Runnable() {
            public void run() {
              ((TextView) view).setText(getText());
            }
          });
        }
      }
      /** 
       * Sets the color of the text content.
       * @param r  Red
       * @param g Green
       * @param b  Blue
       * @param a Alpha
       */
      public void setTextColor(int r, int g, int b, int a) {
        this.textColor = (a << 24) + (r << 16) + (g << 8) + (b);
        if (initialized) {
          pApplet.runOnUiThread(new Runnable() {
            public void run() {
              ((TextView) view).setTextColor(textColor);
            }
          });
        }
      }
      /**
       * Initializes the text field. Is called by {@link APWidgetContainer} 
       * as it is added to it.
       */
      public void init(PApplet pApplet) {
        this.pApplet = pApplet;
    
        ((TextView) view).setText(text);
        if (textColor != -1) {
          ((TextView) view).setTextColor(textColor);
        }
        if (textSize != -1) {
          ((TextView) view).setTextSize(textSize);
        }
    
        ((TextView) view).addTextChangedListener(this);
        super.init(pApplet);
      }
      /**
       * 
       * @return The size of the text content.
       */
      public int getTextSize(){
        return textSize;
      }
      /**
       * 
       * @return The color of the text content.
       */
      public int getTextColor(){
        return textColor;
      }
      /**
       * Updating the {@link #text} variable.
       */
      public void afterTextChanged(Editable s){
        text = ((TextView) view).getText().toString();
      }
      public void beforeTextChanged(CharSequence s, int start, int count, int after){}
      public void onTextChanged(CharSequence s, int start, int before, int count){}
    
    
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.RelativeLayout;
    import java.lang.reflect.Method;
    import java.util.Vector;
    
    import processing.core.PApplet;
    
    public abstract class APWidget implements OnClickListener{
    
      protected int x;
      protected int y;
      protected int width;
      protected int height;
      protected View view;
      protected PApplet pApplet;
      protected boolean initialized = false;
      protected boolean shouldNotSetOnClickListener = false; //some widgets may break if an onClickListener is set, like TextView whos Done and Next etc. buttons don´t work
    
      private Vector<OnClickWidgetListener> onClickWidgetListeners = new Vector<OnClickWidgetListener>();
    
      public void addOnClickWidgetListener(OnClickWidgetListener listener){
        onClickWidgetListeners.addElement(listener);
      }
    
      private Method onClickWidgetMethod;
    
      public View getView() {
        if(!initialized){
          return view;
        }else{
          long time = System.currentTimeMillis();
          while (view == null && System.currentTimeMillis() < time + 1000) {
          }
          return view;
        }
      }
    
      public APWidget(int x, int y, int width, int height) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
      }
    
      public void onClick(View view) {
        if (onClickWidgetMethod != null) {
          try {
            onClickWidgetMethod.invoke(pApplet, new Object[] { this });
          } catch (Exception e) {
          //  System.err.println("Disabling onWidgetEvent() because of an error.");
            e.printStackTrace();
          //  onClickWidgetMethod = null;
          }
        }
        for(int i = 0;i<onClickWidgetListeners.size();i++){
          onClickWidgetListeners.elementAt(i).onClickWidget(this);
        }
      }
    
      public void init(PApplet pApplet) {
        this.pApplet = pApplet;
        // for callbacks
        try {
          onClickWidgetMethod = pApplet.getClass().getMethod("onClickWidget",
              new Class[] { APWidget.class });
        } catch (Exception e) {
          // no such method, or an error.. which is fine, just ignore
        }
        if(!shouldNotSetOnClickListener){
          view.setOnClickListener(this);
        }
        initialized = true;
      }
      public void setPosition(int x, int y){
        this.x = x;
        this.y = y;
        if(initialized){
          pApplet.runOnUiThread(new Runnable() {
            public void run() {
            //  RelativeLayout.LayoutParams relLayout = new RelativeLayout.LayoutParams(rWidth,
            //  rHeight);
            //  relLayout.setMargins(rX, rY, 0, 0);
            //  relLayout.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            //  relLayout.addRule(RelativeLayout.ALIGN_PARENT_TOP);
            //  view.setLayoutParams(relLayout);
              ((RelativeLayout.LayoutParams)view.getLayoutParams()).setMargins(getX(), getY(), 0, 0);
              view.requestLayout();
            }
          });
        }
      }
      public void setSize(int width, int height){
        this.width = width;
        this.height = height;
        if(initialized){
          pApplet.runOnUiThread(new Runnable() {
            public void run() {
              RelativeLayout.LayoutParams relLayout = new RelativeLayout.LayoutParams(getWidth(),
              getHeight());
              relLayout.setMargins(x, y, 0, 0);
              relLayout.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
              relLayout.addRule(RelativeLayout.ALIGN_PARENT_TOP);
              view.setLayoutParams(relLayout);
            }
          });
        }
      }
      public int getX(){
        return x;
      }
      public int getY(){
        return y;
      }
      public int getWidth(){
        return width;
      }
      public int getHeight(){
        return height;
      }
      public PApplet getPApplet(){
        return pApplet;
      }
    }
    
    
    public interface OnClickWidgetListener {
      public void onClickWidget(APWidget widget);
    }
    
    
    import java.util.Vector;
    
    import processing.core.PApplet;
    import android.widget.*;
    import android.view.View;
    import android.view.ViewGroup;
    import android.view.WindowManager;
    
    public class APWidgetContainer{
    
      private void enableGUI(PApplet argPApplet){
        argPApplet.runOnUiThread(new EnableGUITask(argPApplet));
      }
      public APWidgetContainer getThis(){return this;}
    
    
      private int scrollViewID = 983475893;
    
      private MyScrollView scrollView;
      private RelativeLayout layout;
      private PApplet pApplet;
    
      private Vector<View> views = new Vector<View>();
    
      private void createLayout(PApplet pApplet){
        scrollView = new MyScrollView(pApplet);
        scrollView.setFillViewport(true);
        scrollView.setId(scrollViewID);
        pApplet.getWindow().addContentView(
            scrollView,
            new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.FILL_PARENT));
    
        layout = new RelativeLayout(pApplet);
    
        scrollView.addView(layout, new ScrollView.LayoutParams(
                ScrollView.LayoutParams.FILL_PARENT,
                ScrollView.LayoutParams.FILL_PARENT)); //WRAP_CONTENT?
      }
    
      public APWidgetContainer(PApplet pApplet) {
        this.pApplet = pApplet;
      //  enableGUI(pApplet);
        pApplet.runOnUiThread(new Runnable() 
        {
          public void run(){
            if(getPApplet().getWindow().findViewById(scrollViewID)==null){
              createLayout(getPApplet());
            //  System.out.println("create new stuff");
            }else {
              scrollView = (MyScrollView)getPApplet().getWindow().findViewById(scrollViewID);
              layout = (RelativeLayout)scrollView.getChildAt(0);
            //  System.out.println("use existing");
            }
          }
        });
      }
    
      public void addWidget(APWidget pWidget) {
        pApplet.runOnUiThread(new AddWidgetTask(pWidget));
      }
    
      public void removeWidget(APWidget pWidget) {
        pApplet.runOnUiThread(new RemoveWidgetTask(pWidget));
      }
    
    
      public void hide(){
        pApplet.runOnUiThread(new Runnable()
        {
          public void run(){
          //  layout.setVisibility(View.GONE);
            for(int i = 0;i<views.size();i++){
              views.elementAt(i).setVisibility(View.GONE);
            }
          }
        }); 
      }
      //create new and add instead to save resources?
      public void show(){
        pApplet.runOnUiThread(new Runnable()
        {
          public void run(){
          //  viewFlipper.setDisplayedChild(index);
          //  layout.setVisibility(View.VISIBLE);
            for(int i = 0;i<views.size();i++){
              views.elementAt(i).setVisibility(View.VISIBLE);
            }
          }
        });
      }
    
      class AddWidgetTask implements Runnable{
        private APWidget pWidget;
        public AddWidgetTask(APWidget pWidget){
          super();
          this.pWidget = pWidget;
        }
        public void run(){
          pWidget.init(pApplet);
    
          RelativeLayout.LayoutParams relLayout = new RelativeLayout.LayoutParams(pWidget.getWidth(),
              pWidget.getHeight());
          relLayout.setMargins(pWidget.getX(), pWidget.getY(), 0, 0);
          relLayout.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
          relLayout.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    
          layout.addView(pWidget.getView(), relLayout);
    
          views.addElement(pWidget.getView());
        }
      }
    
      class RemoveWidgetTask implements Runnable{
        private APWidget pWidget;
        public RemoveWidgetTask(APWidget pWidget){
          super();
          this.pWidget = pWidget;
        }
        public void run(){
          layout.removeView(pWidget.getView());
          views.removeElement(pWidget.getView());
        }
      }
    
       class EnableGUITask implements Runnable{
        PApplet enableGUITaskPApplet;
        public EnableGUITask(PApplet pApplet){
          enableGUITaskPApplet = pApplet;
        }
        public void run(){
          enableGUITaskPApplet.getWindow().clearFlags(
              WindowManager.LayoutParams.FLAG_FULLSCREEN);
          enableGUITaskPApplet.getWindow().setSoftInputMode(
              WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        }
      }
    
      public PApplet getPApplet(){
        return pApplet;
      }
      public void release(){
        pApplet.stop();
      }
    }
    
  • edited February 2015

    great:) @Akenaton thanks for your help

    After a whole day looking for information on the subject I found the solution here: http://stackoverflow.com/questions/4336762/disabling-the-fullscreen-editing-view-for-soft-keyboard-input-in-landscape

    only is necesary changed:

      textField.setImeOptions(EditorInfo.IME_ACTION_DONE); 
    

    for:

    textField.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);

    right code:

            import apwidgets.*;
            import android.widget.EditText;
            import android.view.inputmethod.InputMethodManager;
            import android.inputmethodservice.KeyboardView.OnKeyboardActionListener;
            import android.view.KeyEvent;
            import android.view.View;
            import android.util.DisplayMetrics;
            import android.net.wifi.WifiInfo;
            import android.net.wifi.WifiManager;
            import android.content.Context;
            import android.content.pm.ActivityInfo;
            import android.content.SharedPreferences;
            import android.content.SharedPreferences.Editor;
            import android.text.InputType;
            import android.view.inputmethod.EditorInfo;
    
    
    
            APWidgetContainer widgetContainer; 
            APEditText textField;
    
          void setup(){
          setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 
          widgetContainer = new APWidgetContainer(this); //create new container for widgets
          textField = new APEditText(20, 10, 150, 50); //create a textfield from x- and y-pos., width and height
          widgetContainer.addWidget(textField); //place textField in container
          textField.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); //Enables a Done button
    
          textField.setCloseImeOnDone(true); 
        }
        String KEY = "";String KEYC = "";
        void draw(){
            background(0); //black background 
        if(mousePressed == true){showVirtualKeyboard();delay(888);}
    
        if(key != 0){ KEY = KEY + int(key)+ "";key = 0;}else{text("KEY",290,222);}
        text(KEY,29,2882);
        text("      L "+KEY,29,222);
        if(random(100) > 99){  text(textField.getText(), 10, 10);} //display the text in the text field
    
        if(keyCode != 0){KEYC = KEYC + int(keyCode);keyCode = 0;}
        text("      LC "+KEYC,29,122);
        }
    
    
          public void showVirtualKeyboard() 
          {
                      InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                      imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
          }
    
  • edited February 2015

    Hi,@akenaton,

    I have a new problem :(

    Once built the textField box, is there effective way to hide it or delete it?

    I see it: editText.setVisibility(View.INVISIBLE)

  • Answer ✓

    in the same situation i have created a button, added a listener and hideSoftInputFromWindow() behaviour...

  • Hi,@akenaton, I think I'm too noob to do that. Can you show me an example code?

  • edited February 2015

    Hi @akenaton,

    I found an easier way to do that. Apparently I have found the solution to my problem. now I

    just need to implement new concepts in my app. :) :) :D

    it work:

    Hide editext box.

    widgetContainer.hide();

    Show editext box:

    widgetContainer.show();

  • Answer ✓

    hi anthony, if I tested your code in processing 3.0 I get some class not found errors. any quick hints?

    thank you ks

Sign In or Register to comment.