Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non-standard textbox behavior in Windows #489

Merged
merged 3 commits into from
Aug 6, 2024

Conversation

RagibHasin
Copy link
Contributor

@RagibHasin RagibHasin commented Aug 6, 2024

No description provided.

@RagibHasin RagibHasin changed the title main Fix non-standard textbox behavior in Windows Aug 6, 2024
Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable, thanks! Using the text field has been on my mental list of things to get around to, but I haven't been able to prioritise.

I've not tested the change myself yet. Will do so once review comments are handled.

masonry/src/text/selection.rs Outdated Show resolved Hide resolved
masonry/src/text/edit.rs Outdated Show resolved Hide resolved
masonry/src/text/selection.rs Outdated Show resolved Hide resolved
@DJMcNab
Copy link
Member

DJMcNab commented Aug 6, 2024

Can you please apply:

From d8f24005fb02dabb8b82837940fc2c192f480908 Mon Sep 17 00:00:00 2001
From: Daniel McNab <[email protected]>
Date: Tue, 6 Aug 2024 17:31:11 +0100
Subject: [PATCH] Remove the conditional for windows

---
 masonry/src/text/edit.rs | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/masonry/src/text/edit.rs b/masonry/src/text/edit.rs
index bf4b28dd..50e41a11 100644
--- a/masonry/src/text/edit.rs
+++ b/masonry/src/text/edit.rs
@@ -190,18 +190,10 @@ impl<T: EditableText> TextEditor<T> {
                         Key::Character(c) => {
                             self.insert_text(event.text.as_ref().unwrap_or(c), ctx)
                         }
-                        Key::Unidentified(_) => {
-                            // Ensures conformance with native Windows behavior in case some
-                            // key event hook sets unidentifed key code and some text for pickup
-                            if cfg!(windows) {
-                                event
-                                    .text
-                                    .as_ref()
-                                    .map_or(Handled::No, |c| self.insert_text(c, ctx))
-                            } else {
-                                Handled::No
-                            }
-                        }
+                        Key::Unidentified(_) => match event.text.as_ref() {
+                            Some(text) => self.insert_text(text, ctx),
+                            None => Handled::No,
+                        },
                         Key::Dead(d) => {
                             eprintln!("Got dead key {d:?}. Will handle");
                             Handled::No
-- 
2.45.2

Because you have chosen to create this PR from your default branch, I can't push to it

Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! We are aware that this code will still have some janky and unexpected behaviour, but it's good to close some holes, anyway.

@DJMcNab DJMcNab added this pull request to the merge queue Aug 6, 2024
Merged via the queue into linebender:main with commit 43ffdbf Aug 6, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants