Skip to main content

ImeRequestData

Struct ImeRequestData 

Source
#[non_exhaustive]
pub struct ImeRequestData { pub hint_and_purpose: Option<(ImeHint, ImePurpose)>, pub cursor_area: Option<(Position, Size)>, pub surrounding_text: Option<ImeSurroundingText>, }
Expand description

The ImeRequest data to communicate to system’s IME.

This applies multiple IME state properties at once. Fields set to None are not updated and the previously sent value is reused.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§hint_and_purpose: Option<(ImeHint, ImePurpose)>

Text input hint and purpose.

To support updating it, enable ImeCapabilities::hint_and_purpose().

§cursor_area: Option<(Position, Size)>

The IME cursor area which should not be covered by the input method popup.

To support updating it, enable ImeCapabilities::cursor_area().

§surrounding_text: Option<ImeSurroundingText>

The text surrounding the caret

To support updating it, enable ImeCapabilities::surrounding_text().

Implementations§

Source§

impl ImeRequestData

Source

pub fn with_hint_and_purpose(self, hint: ImeHint, purpose: ImePurpose) -> Self

Sets the hint and purpose of the current text input content.

Source

pub fn with_cursor_area(self, position: Position, size: Size) -> Self

Sets the IME cursor editing area.

The position is the top left corner of that area in surface coordinates and size is the size of this area starting from the position. An example of such area could be a input field in the UI or line in the editor.

The windowing system could place a candidate box close to that area, but try to not obscure the specified area, so the user input to it stays visible.

The candidate box is the window / popup / overlay that allows you to select the desired characters. The look of this box may differ between input devices, even on the same platform.

(Apple’s official term is “candidate window”, see their chinese and japanese guides).

§Example
// Specify the position in logical dimensions like this:
let ime_request_data = ime_request_data.with_cursor_area(
    LogicalPosition::new(400.0, 200.0).into(),
    LogicalSize::new(100, 100).into(),
);

// Or specify the position in physical dimensions like this:
let ime_request_data = ime_request_data.with_cursor_area(
    PhysicalPosition::new(400, 200).into(),
    PhysicalSize::new(100, 100).into(),
);
§Platform-specific
  • iOS / Android / Web / Orbital: Unsupported.
Source

pub fn with_surrounding_text(self, surrounding_text: ImeSurroundingText) -> Self

Describes the text surrounding the caret.

The IME can then continue providing suggestions for the continuation of the existing text, as well as can erase text more accurately, for example glyphs composed of multiple code points.

Trait Implementations§

Source§

impl Clone for ImeRequestData

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ImeRequestData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ImeRequestData

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for ImeRequestData

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ImeRequestData

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.