Merge pull request #2918 from dcz-self/master
Report cursor size to input method
This commit is contained in:
commit
b89c412496
5 changed files with 36 additions and 25 deletions
|
|
@ -1,5 +1,5 @@
|
|||
//! Listen to input method events.
|
||||
use crate::{Pixels, Point};
|
||||
use crate::{Pixels, Rectangle};
|
||||
|
||||
use std::ops::Range;
|
||||
|
||||
|
|
@ -10,8 +10,10 @@ pub enum InputMethod<T = String> {
|
|||
Disabled,
|
||||
/// Input method is enabled.
|
||||
Enabled {
|
||||
/// The position at which the input method dialog should be placed.
|
||||
position: Point,
|
||||
/// The area of the cursor of the input method.
|
||||
///
|
||||
/// This area should not be covered.
|
||||
cursor: Rectangle,
|
||||
/// The [`Purpose`] of the input method.
|
||||
purpose: Purpose,
|
||||
/// The preedit to overlay on top of the input method dialog, if needed.
|
||||
|
|
@ -85,16 +87,16 @@ impl InputMethod {
|
|||
/// Merges two [`InputMethod`] strategies, prioritizing the first one when both open:
|
||||
/// ```
|
||||
/// # use iced_core::input_method::{InputMethod, Purpose, Preedit};
|
||||
/// # use iced_core::Point;
|
||||
/// # use iced_core::{Point, Rectangle, Size};
|
||||
///
|
||||
/// let open = InputMethod::Enabled {
|
||||
/// position: Point::ORIGIN,
|
||||
/// cursor: Rectangle::new(Point::ORIGIN, Size::UNIT),
|
||||
/// purpose: Purpose::Normal,
|
||||
/// preedit: Some(Preedit { content: "1".to_owned(), selection: None, text_size: None }),
|
||||
/// };
|
||||
///
|
||||
/// let open_2 = InputMethod::Enabled {
|
||||
/// position: Point::ORIGIN,
|
||||
/// cursor: Rectangle::new(Point::ORIGIN, Size::UNIT),
|
||||
/// purpose: Purpose::Secure,
|
||||
/// preedit: Some(Preedit { content: "2".to_owned(), selection: None, text_size: None }),
|
||||
/// };
|
||||
|
|
@ -130,11 +132,11 @@ impl<T> InputMethod<T> {
|
|||
match self {
|
||||
Self::Disabled => InputMethod::Disabled,
|
||||
Self::Enabled {
|
||||
position,
|
||||
cursor,
|
||||
purpose,
|
||||
preedit,
|
||||
} => InputMethod::Enabled {
|
||||
position: *position,
|
||||
cursor: *cursor,
|
||||
purpose: *purpose,
|
||||
preedit: preedit.as_ref().map(Preedit::to_owned),
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue