set_ime_editor_info: accept an 'action: TextInputAction' arg

Makes it possible to configure the action of the IME enter key via
`set_ime_editor_info()`
This commit is contained in:
Robert Bragg
2026-03-02 15:41:26 +00:00
parent 42e0f88287
commit ae24c96dcc
3 changed files with 36 additions and 13 deletions
+16 -7
View File
@@ -214,17 +214,20 @@ impl NativeAppGlue {
self.text_input_state()
}
pub fn set_ime_editor_info(&self, input_type: InputType, options: ImeOptions) {
pub fn set_ime_editor_info(
&self,
input_type: InputType,
action: TextInputAction,
options: ImeOptions,
) {
unsafe {
let activity = (*self.as_ptr()).activity;
let action_id = 0; // IME_ACTION_UNSPECIFIED
// (https://developer.android.com/reference/android/view/inputmethod/EditorInfo#IME_ACTION_DONE)
// TODO: expose this later?
let action_id: i32 = action.into();
ffi::GameActivity_setImeEditorInfo(
activity,
input_type.bits(),
action_id,
action_id as _,
options.bits(),
);
}
@@ -579,8 +582,14 @@ impl AndroidAppInner {
self.native_app.set_text_input_state(state);
}
pub fn set_ime_editor_info(&self, input_type: InputType, options: ImeOptions) {
self.native_app.set_ime_editor_info(input_type, options);
pub fn set_ime_editor_info(
&self,
input_type: InputType,
action: TextInputAction,
options: ImeOptions,
) {
self.native_app
.set_ime_editor_info(input_type, action, options);
}
pub(crate) fn device_key_character_map(
+12 -3
View File
@@ -726,12 +726,21 @@ impl AndroidApp {
self.inner.read().unwrap().set_text_input_state(state);
}
/// Set IME editor flags
pub fn set_ime_editor_info(&self, input_type: input::InputType, options: input::ImeOptions) {
/// Specify the type of text being input, how the IME enter/action key
/// should behave and any additional IME options.
///
/// Also see the Android SDK documentation for
/// [android.view.inputmethod.EditorInfo](https://developer.android.com/reference/android/view/inputmethod/EditorInfo)
pub fn set_ime_editor_info(
&self,
input_type: input::InputType,
action: input::TextInputAction,
options: input::ImeOptions,
) {
self.inner
.read()
.unwrap()
.set_ime_editor_info(input_type, options);
.set_ime_editor_info(input_type, action, options);
}
/// Get an exclusive, lending iterator over buffered input events
+8 -3
View File
@@ -19,8 +19,8 @@ use crate::{
pub mod input;
use crate::input::{
device_key_character_map, Axis, ImeOptions, InputType, KeyCharacterMap, TextInputState,
TextSpan,
device_key_character_map, Axis, ImeOptions, InputType, KeyCharacterMap, TextInputAction,
TextInputState, TextSpan,
};
mod glue;
@@ -387,7 +387,12 @@ impl AndroidAppInner {
}
// TODO: move into a trait
pub fn set_ime_editor_info(&self, _input_type: InputType, _options: ImeOptions) {
pub fn set_ime_editor_info(
&self,
_input_type: InputType,
_action: TextInputAction,
_options: ImeOptions,
) {
// NOP: Unsupported
}