summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXKeyboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/tkMacOSXKeyboard.c')
-rw-r--r--macosx/tkMacOSXKeyboard.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/macosx/tkMacOSXKeyboard.c b/macosx/tkMacOSXKeyboard.c
index db693ea..5952fa3 100644
--- a/macosx/tkMacOSXKeyboard.c
+++ b/macosx/tkMacOSXKeyboard.c
@@ -62,15 +62,13 @@
*
* When the keyboard focus is on a Tk widget which provides text input, there
* are some X11 KeyPress events which cause text to be inserted. We will call
- * these "printable" events. On macOS the text which should be inserted is
- * contained in the xkeys.trans_chars field of a key XEvent as a
- * null-terminated unicode string encoded with a special Tcl encoding. The
- * value of the trans_chars string in an Xevent depends on more than the three
- * items above. It may also depend on the sequence of keypresses that preceded
- * the one being reported by the XEvent. For example, on macOS an <Alt-e>
- * event does not cause text to be inserted but a following <a> event causes an
- * accented 'a' to be inserted. The events in such a composition sequence,
- * other than the final one, are known as "dead-key" events.
+ * these "printable" events. The UCS-32 character stored in the keycode field
+ * of an XKeyEvent depends on more than the three items above. It may also
+ * depend on the sequence of keypresses that preceded the one being reported by
+ * the XKeyEvent. For example, on macOS an <Alt-e> event does not cause text
+ * to be inserted but a following <a> event causes an accented 'a' to be
+ * inserted. The events in such a composition sequence, other than the final
+ * one, are known as "dead-key" events.
*
* MacOS packages the information described above in a different way. Every
* meaningful effect from a key action *other than changing the state of
@@ -488,11 +486,18 @@ TkpGetString(
* result. */
{
(void) winPtr; /*unused*/
- int ch;
+ MacKeycode macKC;
+ char utfChars[8];
+ int length = 0;
+
+ macKC.uint = eventPtr->xkey.keycode;
+ if (IS_PRINTABLE(macKC.v.keychar)) {
+ length = TkUniCharToUtf(macKC.v.keychar, utfChars);
+ }
+ utfChars[length] = 0;
Tcl_DStringInit(dsPtr);
- return Tcl_DStringAppend(dsPtr, eventPtr->xkey.trans_chars,
- TkUtfToUniChar(eventPtr->xkey.trans_chars, &ch));
+ return Tcl_DStringAppend(dsPtr, utfChars, length);
}
/*
@@ -667,7 +672,7 @@ XKeysymToKeycode(
* Modifies the XEvent. Sets the xkey.keycode to a keycode value formatted
* by XKeysymToKeycode and updates the shift and option flags in
* xkey.state if either of those modifiers is required to generate the
- * keysym. Also fills in xkey.trans_chars for printable events.
+ * keysym.
*
*----------------------------------------------------------------------
*/
@@ -718,11 +723,6 @@ TkpSetKeycodeAndState(
}
eventPtr->xkey.keycode = macKC.uint;
eventPtr->xkey.state |= INDEX2STATE(macKC.v.o_s);
- if (IS_PRINTABLE(macKC.v.keychar)) {
- int length = TkUniCharToUtf(macKC.v.keychar,
- eventPtr->xkey.trans_chars);
- eventPtr->xkey.trans_chars[length] = 0;
- }
}
}