Revision: 2404
http://sourceforge.net/p/swingme/code/2404
Author: yuranet
Date: 2021-03-02 15:42:28 +0000 (Tue, 02 Mar 2021)
Log Message:
-----------
better variable names
Modified Paths:
--------------
AndroidME/src_SwingME_plaf/net/yura/android/NativeAndroidTextField.java
Modified: AndroidME/src_SwingME_plaf/net/yura/android/NativeAndroidTextField.java
===================================================================
--- AndroidME/src_SwingME_plaf/net/yura/android/NativeAndroidTextField.java 2021-02-25 11:32:01 UTC (rev 2403)
+++ AndroidME/src_SwingME_plaf/net/yura/android/NativeAndroidTextField.java 2021-03-02 15:42:28 UTC (rev 2404)
@@ -2,11 +2,9 @@
import java.util.ArrayList;
import java.util.List;
-
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Canvas.InputHelper;
import javax.microedition.lcdui.TextBox;
-
import net.yura.android.lcdui.FontManager;
import net.yura.android.plaf.AndroidBorder;
import net.yura.mobile.gui.ActionListener;
@@ -25,7 +23,6 @@
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextWatcher;
-import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.KeyEvent;
@@ -104,7 +101,7 @@
return;
}
- final View view = textBox.getCanvasView();
+ final View canvasView = textBox.getCanvasView();
//System.out.println("[NativeAndroidTextField] ##################### start");
@@ -115,7 +112,7 @@
this.textBox = textBox;
- editText = new NativeEditText(view);
+ editText = new NativeEditText(canvasView);
editText.setGravity( Gravity.TOP ); // on HTC the defualt is center, so we need to set it to top
@@ -196,12 +193,12 @@
// add it to the parent
- ViewGroup group = (ViewGroup)view.getParent();
+ ViewGroup group = (ViewGroup)canvasView.getParent();
int count = group.getChildCount();
List<View> remove = new ArrayList<View>(1);
for (int c=0;c<count;c++) {
View child = group.getChildAt(c);
- if (child != view) {
+ if (child != canvasView) {
remove.add(child);
}
}
@@ -214,9 +211,11 @@
// get focus
- editText.requestFocus();
+ if(editText.requestFocus()) {
+ // if we want to open the keyboard as soon as the textbox becomes focused
+ //((InputMethodManager)editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
+ }
-
TextComponent.staticFocusListener = this;
// // get old focusListeners, we will keep this copy
// focusListeners = textField.getFocusListeners();
@@ -226,7 +225,6 @@
// }
// // add ourselves to listen for focus
// textField.addFocusListener(this);
-
}
// ChangeListener[] focusListeners;
@@ -447,11 +445,11 @@
class NativeEditText extends EditText {
- View view;
+ View canvasView;
public NativeEditText(View view) {
super( AndroidMeActivity.DEFAULT_ACTIVITY );
- this.view = view;
+ this.canvasView = view;
}
/*
@@ -547,7 +545,7 @@
protected void onSelectionChanged(int selStart, int selEnd) {
try {
- if (view!=null) { // we check the view is not null to make sure this is not the call from the constructor
+ if (canvasView !=null) { // we check the view is not null to make sure this is not the call from the constructor
int caretPosition = textField.getCaretPosition();
@@ -573,7 +571,7 @@
android2swing(); // send text to swingME
//b.fireActionPerformed();// WE CAN NOT FIRE THE BUTTON DIRECTLY, as this may be the menu button
- boolean use = view.onKeyDown(keyCode, event); // we pass this event to AndroidME, for it to send it to SwingME
+ boolean use = canvasView.onKeyDown(keyCode, event); // we pass this event to AndroidME, for it to send it to SwingME
// ========== SWING 2 MIDP ==========
// get the text from swingME to J2ME
@@ -585,7 +583,7 @@
}
boolean use = super.onKeyDown(keyCode, event);
- if (!use) return view.onKeyDown(keyCode, event);
+ if (!use) return canvasView.onKeyDown(keyCode, event);
return true;
}
@@ -592,7 +590,7 @@
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
boolean use = super.onKeyUp(keyCode, event);
- if (!use) return view.onKeyUp(keyCode, event);
+ if (!use) return canvasView.onKeyUp(keyCode, event);
return true;
}
@@ -599,7 +597,7 @@
@Override
public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {
boolean use = super.onKeyMultiple(keyCode, repeatCount, event);
- if (!use) return view.onKeyMultiple(keyCode, repeatCount, event);
+ if (!use) return canvasView.onKeyMultiple(keyCode, repeatCount, event);
return true;
}
@@ -606,7 +604,7 @@
@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
boolean use = super.onKeyPreIme(keyCode, event);
- if (!use) return view.onKeyPreIme(keyCode, event);
+ if (!use) return canvasView.onKeyPreIme(keyCode, event);
return true;
}
@@ -613,7 +611,7 @@
@Override
public boolean onKeyShortcut(int keyCode, KeyEvent event) {
boolean use = super.onKeyShortcut(keyCode, event);
- if (!use) return view.onKeyShortcut(keyCode, event);
+ if (!use) return canvasView.onKeyShortcut(keyCode, event);
return true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|