Revision: 2937
http://sourceforge.net/p/swingme/code/2937
Author: yuranet
Date: 2025-11-23 18:05:39 +0000 (Sun, 23 Nov 2025)
Log Message:
-----------
fix for native android text entry
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 2025-11-23 13:48:10 UTC (rev 2936)
+++ AndroidME/src_SwingME_plaf/net/yura/android/NativeAndroidTextField.java 2025-11-23 18:05:39 UTC (rev 2937)
@@ -134,7 +134,6 @@
}
@Override
public void onTextChanged(CharSequence cs, int i, int i1, int i2) {
-
try {
android2swing();
}
@@ -142,7 +141,6 @@
//#debug debug
Logger.warn("[NativeAndroidTextField] error in onTextChanged "+editText+" PLEASE SHOW YURA!!!", ex);
}
-
}
@Override
public void afterTextChanged(Editable edtbl) {
@@ -249,7 +247,6 @@
DesktopPane.mySizeChanged(textField);
}
-
}
int tx=-100,ty=-100,tw=-100,th=-100; // some random none valid numbers
@@ -257,8 +254,9 @@
// this is the only swing me specific method
- int x = textField.getXOnScreen();
- int y = textField.getYOnScreen();
+ Canvas.CanvasView canvasView = textBox.getCanvasView();
+ int x = canvasView.getPaddingLeft() + textField.getXOnScreen();
+ int y = canvasView.getPaddingTop() + textField.getYOnScreen();
int w = textField.getWidth();
int h = textField.getHeight();
@@ -341,18 +339,18 @@
//System.out.println("[NativeAndroidTextField] ##################### close");
- Canvas.CanvasView view = textBox.getCanvasView();
+ Canvas.CanvasView canvasView = textBox.getCanvasView();
- view.requestFocus();
+ canvasView.requestFocus();
// remove it
- final ViewGroup group = (ViewGroup)view.getParent();
+ final ViewGroup group = (ViewGroup)canvasView.getParent();
int count = group.getChildCount();
final 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);
}
}
@@ -384,10 +382,9 @@
android2swing();
// reset everything in the class
- view.clearInputHelper();
+ canvasView.clearInputHelper();
editText = null;
tx=-100;ty=-100;tw=-100;th=-100;
-
}
void midp2android() {
@@ -543,6 +540,13 @@
*/
@Override
protected void onSelectionChanged(int selStart, int selEnd) {
+ try {
+ super.onSelectionChanged(selStart, selEnd);
+ }
+ catch (Throwable th) {
+ //#debug debug
+ Logger.warn("Error in super.onSelectionChanged selStart="+selStart+" selEnd="+selEnd+" textField: >"+textField+"< >"+this+"< >"+getText()+"< PLEASE SHOW YURA!!!", th);
+ }
try {
if (canvasView !=null) { // we check the view is not null to make sure this is not the call from the constructor
@@ -567,7 +571,7 @@
Window win = textField.getWindow();
Button b = win.findMnemonicButton(swingMeCode);
- if (b!=null) {
+ if (b != null) {
android2swing(); // send text to swingME
//b.fireActionPerformed();// WE CAN NOT FIRE THE BUTTON DIRECTLY, as this may be the menu button
@@ -623,7 +627,6 @@
return true;
}
*/
-
}
public static void setNativeSettings(final EditText editText, TextComponent textField, int constraints,String initialInputMode) {
@@ -661,5 +664,4 @@
editText.setHint(hint);
}
}
-
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|