Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

only clicking on text will move cursor

prevents misclicks
  • Loading branch information...
commit ee5b7a61ee35c585fa0737d7fd884940d22d307a 1 parent dc7391c
@Xlythe authored
Showing with 10 additions and 1 deletion.
  1. +10 −1 src/com/android2/calculator3/CalculatorDisplay.java
View
11 src/com/android2/calculator3/CalculatorDisplay.java
@@ -22,17 +22,19 @@
import android.text.Spanned;
import android.text.method.NumberKeyListener;
import android.util.AttributeSet;
+import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.animation.TranslateAnimation;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.ViewSwitcher;
+import android.view.View.OnLongClickListener;
/**
* Provides vertical scrolling for the input/result EditText.
*/
-class CalculatorDisplay extends ViewSwitcher {
+class CalculatorDisplay extends ViewSwitcher implements OnLongClickListener {
private static final String ATTR_MAX_DIGITS = "maxDigits";
private static final int DEFAULT_MAX_DIGITS = 10;
@@ -71,6 +73,7 @@ public CalculatorDisplay(Context context, AttributeSet attrs) {
mModString = context.getResources().getString(R.string.mod);
mDX = context.getResources().getString(R.string.dx);
mDY = context.getResources().getString(R.string.dy);
+ setOnLongClickListener(this);
}
public int getMaxDigits() {
@@ -182,6 +185,7 @@ else if(textBeforeInsertionHandle.endsWith(mDY + "(")) {
text.setEditableFactory(factory);
text.setKeyListener(calculatorKeyListener);
text.setSingleLine();
+ text.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL));
}
}
@@ -264,4 +268,9 @@ protected void onFocusChanged(boolean gain, int direction, Rect prev) {
requestFocus();
}
}
+
+ @Override
+ public boolean onLongClick(View v) {
+ return getCurrentView().performLongClick();
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.