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
assign a key code to events when “typing” text #1827
Conversation
some applications only look at the key code and ignore the unicode value fixes #1792
I found another place where the issue can be reproduced. If you have XQuartz installed and use Type Text in One remaining problem is that characters that require modifiers are still wrong. For example, |
Nice, I can reproduce, and can see your fix
That was probably just overlooked, yes, they should always be sent I've tried and tried to get things like the |
@@ -60,11 +60,19 @@ - (QSObject *)typeObject:(QSObject *)dObject { | |||
|
|||
- (void)typeString:(NSString *)string { | |||
UniChar buffer; | |||
CGKeyCode keyCode; | |||
CGEventRef keyEvent = CGEventCreateKeyboardEvent(NULL, 0, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point in creating an even here that's never used?
Why not just CGEventRef keyEvent = NULL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got that from you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hehe. Oops :P
That comment was meant to errr... try and catch you out? FWIW I did a quick test without it and it seemed to work fine
(Is this something we should write a unit test for, since there are lots of edge cases? If not, maybe we should at least put in the comments to the methods things like:
- Xterm is dodgy, as is RemoteDesktop
- Some apps only work with key codes and not the unicode string
- etc.
)
For the record, here are my results (running vanilla 400A) :
I'll try to give a spin to it tonight, as well as checking it against my NDKeyboard branch. But again, I don't remember a way of reconstructing a "keycode sequence" from a given string in |
Actually, it works in most apps (even with a US keyboard) because they seem to use the key event’s unicode string instead of its key code. We only see problems in places that rely on the key code (XQuartz and MS Remote Desktop).
That was fixed (on this branch) by supplying a key code and sending the corresponding key up events, but that only works for things that can be typed without modifiers. |
Does trying to
Ok, I'll try to see if there's a way to extend NDKeyboard to handle that for us. |
No. I tried that, and all other combinations. Still a problem. For the record, I tried:
Nothing worked for the one case of typing ‘:’ into Xterm. It always gave me ‘a’. On 28 Ebrill 2014, at 20:11, Etienne Samson notifications@github.com wrote:
|
Since I think this is an uncommon edge case, and it was broken anyway (and we need to get that stupid v1.2 release out!), I'm going to merge this. We should keep #1792 open to remind us of the |
assign a key code to events when “typing” text
Agreed. Thanks. |
Thanks to CoRD being open source, I was able to run it in a debugger and examine the keyboard behavior, which gave me some ideas that led to the answer. The answer, by the way, is right there in the comments for
CGEventKeyboardSetUnicodeString()
:Remote Desktop clients apparently fall into this category.
I notice that we’re only sending key down events, but never sending the corresponding up event. It seems to work anyway, but should we fix that?
Also note that Type Text still mangles certain characters in Unicode-string-ignoring apps, but that was probably always the case. I can live with it.