Draft input_method support
This commit is contained in:
parent
599d8b560b
commit
7db5256b72
13 changed files with 420 additions and 27 deletions
|
|
@ -4,7 +4,7 @@ use crate::core::{Color, Size};
|
|||
use crate::graphics::Viewport;
|
||||
use crate::program::Program;
|
||||
|
||||
use winit::event::{Touch, WindowEvent};
|
||||
use winit::event::{Ime, Touch, WindowEvent};
|
||||
use winit::window::Window;
|
||||
|
||||
use std::fmt::{Debug, Formatter};
|
||||
|
|
@ -22,6 +22,7 @@ where
|
|||
modifiers: winit::keyboard::ModifiersState,
|
||||
theme: P::Theme,
|
||||
style: theme::Style,
|
||||
preedit: String,
|
||||
}
|
||||
|
||||
impl<P: Program> Debug for State<P>
|
||||
|
|
@ -73,6 +74,7 @@ where
|
|||
modifiers: winit::keyboard::ModifiersState::default(),
|
||||
theme,
|
||||
style,
|
||||
preedit: String::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -136,6 +138,11 @@ where
|
|||
self.style.text_color
|
||||
}
|
||||
|
||||
/// TODO
|
||||
pub fn preedit(&self) -> String {
|
||||
self.preedit.clone()
|
||||
}
|
||||
|
||||
/// Processes the provided window event and updates the [`State`] accordingly.
|
||||
pub fn update(
|
||||
&mut self,
|
||||
|
|
@ -179,6 +186,11 @@ where
|
|||
WindowEvent::ModifiersChanged(new_modifiers) => {
|
||||
self.modifiers = new_modifiers.state();
|
||||
}
|
||||
WindowEvent::Ime(ime) => {
|
||||
if let Ime::Preedit(text, _) = ime {
|
||||
self.preedit = text.clone();
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "debug")]
|
||||
WindowEvent::KeyboardInput {
|
||||
event:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue