Tk Source Code

View Ticket
Bounty program for improvements to Tcl and certain Tcl packages.
Ticket UUID: 39de9677aa51fd3372903c6a72b1d6e1e3636
Title: Typing Japanese through IME [macOS]
Type: Bug Version: LATEST
Submitter: Takamoto Created on: 2019-09-22 16:02:12
Subsystem: (unused) Assigned To: marc_culler
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2020-04-20 21:03:27
Resolution: Fixed Closed By: marc_culler
    Closed on: 2020-04-20 21:03:27
On a macOS (Mojave) entering text in any widget (Entry for example) is a cumbersome when using IME for Japanese (but it probably applies to other languages too). After a word is highlighted in the IME, clicking Enter causes the IME window to disappear, but no word is inserted in the Widget. To insert it, a second Enter stroke with the widget in focus is needed in order for the word to appear in the widget. On other software, highlighting a word in IME and hitting Enter causes the word to be inserted in the widgets.In Tk this needs to be done twice, which results in a cumbersome and contra intuitive behaviour.

To replicate this, a simple Entry widget is needed, plus keyboard layout needs to be set to Hiragana.

label .l -text "Enter:"
entry .e -width 40 -relief sunken -bd 2 -textvariable name
focus .e
button .b -text Clear -command {set name ""}
grid .l -row 0 -column 0 -sticky e
grid .e -row 0 -column 1 -sticky w
grid .b -row 1 -column 0 -columnspan 2
User Comments: Takamoto added on 2019-10-27 15:08:37:
With some delay on my side. This is a HUGE improvement. I have not been able to test it in detail, but the behaviour seems fine to me now. I will report any problem if encountered.

marc_culler (claiming to be Marc Culler) added on 2019-10-25 18:11:09:
After a very helpful review by Kevin Walzer I have merged the bugfix branch
into core-8-6-branch and trunk.

There may be issues remaining that will be noticed by experienced IME users, but
to naive users like us it appears to work.  If other problems emerge we can
reopen this ticket.

marc_culler (claiming to be Marc Culler) added on 2019-10-25 01:54:05:
The bugfix branch now provides support for Apple's "accent menu" which pops up
when a key is pressed and held for a long enough time.  A menu is popped up with
a list of ways to accent the character.  An accent can be selected by typing a
numerical key 1-9 and the accented character is inserted.  This works for
entry, ttk::entry and text widgets.  If the bug fix branch were committed it
would also resolve [92b887ca13].

marc_culler (claiming to be Marc Culler) added on 2019-10-24 13:55:31:
Well, there was quite a bit more work to do.  But I think the tip of the bug fix
branch is now solid and I would really like to hear comments from testers,
especially people who use IME frequently.

marc_culler (claiming to be Marc Culler) added on 2019-10-23 01:40:58:

I think this is mostly fixed in commit e48b918ded to the branch bug-39de9677aa. That commit also fixes many of the issues with the "Emoji & Symbols" item in the standard Edit menu. I have tested with a Hiragana keyboard and the Character Palette. But it would be very helpful if someone who uses IME heavily could look at it. Also, I am sure that there are widgets that I have missed which will need some Tcl support to work correctly.

@Takamoto: would you please review the bug fix branch? Does it behave the way you expect?

Note: in IME it is required that the proposed characters be highlighted somehow until they are selected. Normally that is done with an underline. But it did not seem possible to mix two different fonts in the Entry. As a workaround I opted to highlight the "marked text" by selecting it, so it is rendered with a different background color. In the Text widget I was able to use an underline.

kevin_walzer added on 2019-09-24 02:46:38:
I'll acknowledge that the implementation here of the Cocoa Text Input API is not perfect. The developer of this feature, Adrian Robert, has moved on from Tcl/Tk development. His work was a great first attempt to meld the text input API with Tk, and the development of the patch is documented here:

I've looked at the code, but as with many aspects of Tk, my expertise is not the same as that as those who developed the original feature. I'll leave this bug report open and invite a patch if you feel like submitting one.