Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Simplify input handling (#3282)

Nathan Sobo8c44f6a81422
diff --cc crates/gpui2/src/window.rs
index ce50b8e7f11,29980a486b7..ac7dcf02569
--- a/crates/gpui2/src/window.rs
+++ b/crates/gpui2/src/window.rs
@@@ -2182,14 -2169,29 +2177,29 @@@ impl<'a, V: 'static> ViewContext<'a, V
})
});
}
+
+ /// Set an input handler, such as [ElementInputHandler], which interfaces with the
+ /// platform to receive textual input with proper integration with concerns such
+ /// as IME interactions.
+ pub fn handle_input(
+ &mut self,
+ focus_handle: &FocusHandle,
+ input_handler: impl PlatformInputHandler,
+ ) {
+ if focus_handle.is_focused(self) {
+ self.window
+ .platform_window
+ .set_input_handler(Box::new(input_handler));
+ }
+ }
}
-impl<V> ViewContext<'_, V>
-where
- V: EventEmitter,
- V::Event: 'static,
-{
- pub fn emit(&mut self, event: V::Event) {
+impl<V> ViewContext<'_, V> {
+ pub fn emit<Evt>(&mut self, event: Evt)
+ where
+ Evt: 'static,
+ V: EventEmitter<Evt>,
+ {
let emitter = self.view.model.entity_id;
self.app.push_effect(Effect::Emit {
emitter,