Simplify IME support
This commit is contained in:
parent
97ce9e9586
commit
9a022671a2
8 changed files with 148 additions and 218 deletions
|
@ -211,7 +211,6 @@ pub struct Window {
|
|||
default_prevented: bool,
|
||||
mouse_position: Point<Pixels>,
|
||||
requested_cursor_style: Option<CursorStyle>,
|
||||
pub(crate) requested_input_handler: Option<Box<dyn PlatformInputHandler>>,
|
||||
scale_factor: f32,
|
||||
bounds: WindowBounds,
|
||||
bounds_observers: SubscriberSet<(), AnyObserver>,
|
||||
|
@ -236,6 +235,7 @@ pub(crate) struct Frame {
|
|||
content_mask_stack: Vec<ContentMask<Pixels>>,
|
||||
element_offset_stack: Vec<Point<Pixels>>,
|
||||
focus_stack: Vec<FocusId>,
|
||||
input_handler: Option<Box<dyn PlatformInputHandler>>,
|
||||
}
|
||||
|
||||
impl Window {
|
||||
|
@ -311,7 +311,6 @@ impl Window {
|
|||
default_prevented: true,
|
||||
mouse_position,
|
||||
requested_cursor_style: None,
|
||||
requested_input_handler: None,
|
||||
scale_factor,
|
||||
bounds,
|
||||
bounds_observers: SubscriberSet::new(),
|
||||
|
@ -1048,9 +1047,6 @@ impl<'a> WindowContext<'a> {
|
|||
.take()
|
||||
.unwrap_or(CursorStyle::Arrow);
|
||||
self.platform.set_cursor_style(cursor_style);
|
||||
if let Some(handler) = self.window.requested_input_handler.take() {
|
||||
self.window.platform_window.set_input_handler(handler);
|
||||
}
|
||||
|
||||
self.window.dirty = false;
|
||||
}
|
||||
|
@ -2174,6 +2170,16 @@ impl<'a, V: 'static> ViewContext<'a, V> {
|
|||
})
|
||||
});
|
||||
}
|
||||
|
||||
pub fn handle_input(
|
||||
&mut self,
|
||||
focus_handle: &FocusHandle,
|
||||
input_handler: impl PlatformInputHandler,
|
||||
) {
|
||||
if focus_handle.is_focused(self) {
|
||||
self.window.current_frame.input_handler = Some(Box::new(input_handler));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<V> ViewContext<'_, V>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue