Deleting selected text

This commit is contained in:
2024-10-10 21:23:50 +02:00
parent 1da4ffbc17
commit d7134a51d0
3 changed files with 14 additions and 3 deletions
@@ -1,5 +1,6 @@
package cfpi_fpsi.eu.titanboard;
import android.annotation.SuppressLint;
import android.inputmethodservice.InputMethodService;
import android.os.Build;
import android.os.Vibrator;
@@ -96,9 +97,12 @@ public class TitanboardIME extends InputMethodService {
return false;
// If it's the backspace key, we remove one character.
case KeyEvent.KEYCODE_DEL:
conn.deleteSurroundingText(1, 0);
adjustMetaKeyStateAfterKeypress();
return true;
if (conn.getSelectedText(0) == null) {
conn.deleteSurroundingText(1, 0);
return true;
}
return false;
case KeyEvent.KEYCODE_SPACE:
conn.commitText(" ", 1);
adjustMetaKeyStateAfterKeypress();
@@ -196,6 +200,9 @@ public class TitanboardIME extends InputMethodService {
mMetaKeyLatched = MetaKey.NONE;
mMetaKeyLocked = MetaKey.NONE;
updateMetaStateTextView();
mInputView.findViewById(R.id.extra_view).setVisibility(View.GONE);
Button key = (Button) mInputView.findViewById(R.id.expand_button);
key.setText("▲");
}
private String getKey(int keyCode) {
@@ -216,6 +223,7 @@ public class TitanboardIME extends InputMethodService {
}
}
@SuppressLint("SetTextI18n")
private void updateMetaStateTextView() {
TextView stateView = mInputView.findViewById(R.id.state);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+3 -1
View File
@@ -41,7 +41,8 @@
android:layout_width="10dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="aa" />
android:text="aa"
android:typeface="normal" />
</LinearLayout>
@@ -240,6 +241,7 @@
android:text="&amp;" />
<Button
android:id="@+id/expand_button"
style="@style/KeyboardKey"
android:layout_width="wrap_content"
android:layout_height="match_parent"
+1
View File
@@ -17,6 +17,7 @@
<item name="android:textColor">#AAA</item>
<item name="android:textSize">18sp</item>
<item name="android:textAlignment">center</item>
<item name="android:typeface">monospace</item>
<item name="android:layout_weight">1</item>
<item name="android:width">0px</item>
</style>