Hello,
I'm trying to hide an apwidget textfield, and I'm having trouble getting it to work. My goal is to have an app that will connect via osc to a desktop computer, I want to be able to enter an ip adress and a port number for OSC connection.
I can use the .show() and .hide() function pretty easily but when I click the widget to enter a number, hide and show doesn't work anymore. I guess it's coming from focus that is taken from the widget and not given back afterwards.
Here's some code :
in my setup()
- // text widget IP
- ipContainer = new APWidgetContainer( this );
- ipPhoneNumberField = new APEditText( myWidth/4, myHeight/2, myWidth/2, 100 );
- ipContainer.addWidget(ipPhoneNumberField);
- ipPhoneNumberField.setInputType(InputType.TYPE_CLASS_PHONE); //Set input type to numb keypad
- ipPhoneNumberField.setImeOptions(EditorInfo.IME_ACTION_DONE); //Enables a Done button
- ipPhoneNumberField.setCloseImeOnDone(true); //close the IME when done is pressed
-
- // text widget Port
- pPhoneNumberField = new APEditText( myWidth/4, myHeight*3/4, myWidth/2, 100 );
- ipContainer.addWidget(pPhoneNumberField);
- pPhoneNumberField.setInputType(InputType.TYPE_CLASS_PHONE); //Set input type to numb keypad
- pPhoneNumberField.setImeOptions(EditorInfo.IME_ACTION_DONE); //Enables a Done button
- pPhoneNumberField.setCloseImeOnDone(true); //close the IME when done is pressed
then I've use a function to show/hide stuff when clicking the device's menu button :
- public void keyPressed() {
- if (keyCode == KeyEvent.KEYCODE_MENU ){
- if (!menu){
- menu = true;
- ipContainer.show();
- }
- else {
- menu = false;
- ipContainer.hide();
- }
- }
- }
if I use
- .getView().setVisible(false);
I get an error (I'm in eclipse, so he won't let me compile), eclipse suggests to use setVisibility(int myInt) instead, I tried but it just doesn't show or hide anymore even without giving focus to the widget.
So I don't know how to solve this, does anyone has an idea how to show hide widget pressing the menu button ?
cheers