Simplify input handling (#3282)
This PR takes a different approach to input handling. Rather than returning the optional input handler, focus handle pair from the element trait, we instead allow you to register an input handler imperatively on the window context with `WindowContext::handle_input`. You pass a focus handle reference and any implementer of `PlatformInputHandler`. There's an `ElementInputHandler<V>` that implements `PlatformWindowHandler` so long as `V` implements `InputHandler`. Release Notes: - N/A
This commit is contained in:
commit
8c44f6a814
8 changed files with 145 additions and 218 deletions
|
@ -9580,7 +9580,7 @@ impl Render for Editor {
|
|||
|
||||
impl InputHandler for Editor {
|
||||
fn text_for_range(
|
||||
&self,
|
||||
&mut self,
|
||||
range_utf16: Range<usize>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Option<String> {
|
||||
|
@ -9593,7 +9593,7 @@ impl InputHandler for Editor {
|
|||
)
|
||||
}
|
||||
|
||||
fn selected_text_range(&self, cx: &mut ViewContext<Self>) -> Option<Range<usize>> {
|
||||
fn selected_text_range(&mut self, cx: &mut ViewContext<Self>) -> Option<Range<usize>> {
|
||||
// Prevent the IME menu from appearing when holding down an alphabetic key
|
||||
// while input is disabled.
|
||||
if !self.input_enabled {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue