summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-05-07 04:29:37 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-05-07 04:29:37 -0400
commit58aa0ea407aedde32cbde69b2dbb6cf4ae9e31a5 (patch)
tree298c3400f22f4ca9b84beb0a3df7f55bbabc9003
parent42d03f38e3cccad38a1e3000e180662b378343c3 (diff)
implement backspace
-rw-r--r--res/layout/ime.xml8
-rw-r--r--src/us/minak/IMEView.java14
2 files changed, 22 insertions, 0 deletions
diff --git a/res/layout/ime.xml b/res/layout/ime.xml
index 83be9d2..53f8fdf 100644
--- a/res/layout/ime.xml
+++ b/res/layout/ime.xml
@@ -20,4 +20,12 @@
android:gestureStrokeSquarenessThreshold="0.0"
android:gestureStrokeType="multiple" />
+ <Button
+ android:id="@+id/backspace_btn"
+ android:text="@string/button_backspace"
+
+ android:layout_width="80dp"
+ android:layout_height="40dp"
+ android:layout_alignParentRight="true" />
+
</us.minak.IMEView>
diff --git a/src/us/minak/IMEView.java b/src/us/minak/IMEView.java
index dd2fb69..31ce553 100644
--- a/src/us/minak/IMEView.java
+++ b/src/us/minak/IMEView.java
@@ -2,7 +2,9 @@ package us.minak;
import android.content.Context;
import android.util.AttributeSet;
+import android.widget.Button;
import android.widget.RelativeLayout;
+import android.view.View;
import android.view.inputmethod.InputConnection;
/**
@@ -17,6 +19,12 @@ public class IMEView extends RelativeLayout implements InputConnectionGetter {
protected void onFinishInflate() {
IMEGestureOverlayView gestureOverlayView = (IMEGestureOverlayView) findViewById(R.id.drawing_space);
gestureOverlayView.setInputConnectionGetter(this);
+
+ final Button backspaceButton = (Button) findViewById(R.id.backspace_btn);
+ backspaceButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) { backspace(); }
+ });
}
private InputConnectionGetter icGetter = new InputConnectionGetter.NullGetter();
@@ -27,4 +35,10 @@ public class IMEView extends RelativeLayout implements InputConnectionGetter {
public InputConnection getCurrentInputConnection() {
return icGetter.getCurrentInputConnection();
}
+
+ private void backspace() {
+ InputConnection ic = getCurrentInputConnection();
+ if (ic != null)
+ ic.deleteSurroundingText(1, 0);
+ }
}