diff options
-rw-r--r-- | res/layout/ime.xml | 8 | ||||
-rw-r--r-- | src/us/minak/IMEView.java | 14 |
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); + } } |