forked from iced-rs/iced
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ime_adavanced_text' into upstream20231122
- Loading branch information
Showing
53 changed files
with
906 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
//! Access the IME. | ||
mod event; | ||
|
||
pub use event::Event; | ||
|
||
/// IME Access interface. | ||
pub trait IME { | ||
/// | ||
fn set_ime_position(&self, x: i32, y: i32); | ||
|
||
/// need to call if clicked position is widget's region. | ||
/// | ||
/// IME willbe enabled. | ||
fn inside(&self); | ||
|
||
/// need to call if clicked position is not widget's region. | ||
/// | ||
/// used to determine disable ime. | ||
fn outside(&self); | ||
|
||
/// disable IME. | ||
/// | ||
fn password_mode(&self); | ||
|
||
/// force ime enabled or disabled. | ||
/// | ||
/// this will block request until unlock_set_ime_allowed. | ||
fn force_set_ime_allowed(&self, _allowed: bool); | ||
/// remove request of force_set_ime_allowed | ||
/// | ||
fn unlock_set_ime_allowed(&self); | ||
|
||
#[cfg(target_os = "macos")] | ||
/// macos's strange behavior of set_ime_position workaround. | ||
/// | ||
/// on macos we can't move cadidate window by set_ime_position. | ||
/// | ||
/// we set ime candidate window position by these steps when IME::Commit event processed. | ||
/// | ||
/// * disable IME | ||
/// * set candidate position | ||
/// * enable IME | ||
fn set_ime_position_with_reenable(&self, x: i32, y: i32); | ||
} | ||
|
||
/// A null implementation of the [`IME`] trait. | ||
#[derive(Debug, Clone, Copy)] | ||
pub struct Null; | ||
|
||
impl IME for Null { | ||
fn set_ime_position(&self, _x: i32, _y: i32) {} | ||
|
||
fn outside(&self) {} | ||
|
||
fn password_mode(&self) {} | ||
|
||
fn inside(&self) {} | ||
|
||
fn force_set_ime_allowed(&self, _: bool) {} | ||
|
||
fn unlock_set_ime_allowed(&self) {} | ||
#[cfg(target_os = "macos")] | ||
fn set_ime_position_with_reenable(&self, _x: i32, _y: i32) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/// A IME event. | ||
/// | ||
/// _**Note:** This type is largely incomplete! If you need to track | ||
/// additional events, feel free to [open an issue] and share your use case!_ | ||
/// | ||
/// [open an issue]: https://github.com/iced-rs/iced/issues | ||
#[derive(Debug, Clone, PartialEq, Eq)] | ||
pub enum Event { | ||
/// IME enabled. | ||
IMEEnabled, | ||
|
||
/// selecting input. | ||
IMEPreedit(String, Option<(usize, usize)>), | ||
|
||
/// enter input. | ||
IMECommit(String), | ||
/// Notifies when the IME was disabled. | ||
IMEDisabled, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.