diff --git a/android-activity/src/game_activity/mod.rs b/android-activity/src/game_activity/mod.rs index 0308dbd..53889cf 100644 --- a/android-activity/src/game_activity/mod.rs +++ b/android-activity/src/game_activity/mod.rs @@ -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( diff --git a/android-activity/src/lib.rs b/android-activity/src/lib.rs index a5d2ec3..f9298fa 100644 --- a/android-activity/src/lib.rs +++ b/android-activity/src/lib.rs @@ -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 diff --git a/android-activity/src/native_activity/mod.rs b/android-activity/src/native_activity/mod.rs index 0130c37..74f2925 100644 --- a/android-activity/src/native_activity/mod.rs +++ b/android-activity/src/native_activity/mod.rs @@ -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 }