Skip to content

IME and the MacOS Character Viewer #3342

Open

Description

@HolgerGottChristensen

I have an application based on winit 0.29.7.
On MacOS you can open the character viewer using the fn/🌐 key.
Screenshot 2023-12-30 at 18 07 14

This seem to be the preferred way of inserting symbols and emojis into text fields in an application.
When I double click one of the characters (which inserts it into other applications), no events are sent from winit.

Screen.Recording.2023-12-30.at.18.16.45.mov

I have experimented more with winit, and it seems that it has to do with the IME implementation.
When I enable IME it still does not send events, but when IME has started, for example by typing the ¨ character, I can then insert emojis by double clicking on the character viewer.

Screen.Recording.2023-12-30.at.18.20.11.mov

When I end the IME for example by typing e, the events of the character viewer stops being sent again.

I looked into the MacOS implementation of winit.
The events from MacOS are sent through the insertText:replacementRange: event handler in the file src/platform_impl/macos/view.rs file.

I have tried debugging the issue, and inserting a dbg in the method:
Screenshot 2023-12-30 at 18 29 56

When clicking the character viewer, the following is printed, when IME is not started:

TRACE [winit::platform_impl::platform::view] Triggered `insertText:replacementRange:`
[src/platform_impl/macos/view.rs:398] &string = "😀"
TRACE [winit::platform_impl::platform::view] Triggered `hasMarkedText`
TRACE [winit::platform_impl::platform::view] Completed `hasMarkedText`
[src/platform_impl/macos/view.rs:398] unsafe { self.hasMarkedText() } = false
[src/platform_impl/macos/view.rs:398] self.is_ime_enabled() = false
[src/platform_impl/macos/view.rs:398] !is_control = true
TRACE [winit::platform_impl::platform::view] Triggered `hasMarkedText`
TRACE [winit::platform_impl::platform::view] Completed `hasMarkedText`
TRACE [winit::platform_impl::platform::view] Completed `insertText:replacementRange:`

When IME is started(by pressing ¨), it prints the following:

TRACE [winit::platform_impl::platform::view] Triggered `insertText:replacementRange:`
[src/platform_impl/macos/view.rs:396] &string = "😀"
TRACE [winit::platform_impl::platform::view] Triggered `hasMarkedText`
TRACE [winit::platform_impl::platform::view] Completed `hasMarkedText`
[src/platform_impl/macos/view.rs:396] unsafe { self.hasMarkedText() } = true
[src/platform_impl/macos/view.rs:396] self.is_ime_enabled() = true
[src/platform_impl/macos/view.rs:396] !is_control = true
TRACE [winit::platform_impl::platform::view] Triggered `hasMarkedText`
TRACE [winit::platform_impl::platform::view] Completed `hasMarkedText`
TRACE [winit::platform_impl::platform::view] Completed `insertText:replacementRange:`

and sends the events:

WindowEvent { window_id: WindowId(WindowId(5735737648)), event: Ime(Preedit("", None)) }
WindowEvent { window_id: WindowId(WindowId(5735737648)), event: Ime(Commit("😀")) }

If anything is missing I will try my best to provide it.

Activity

  1. added
    DS - appkit
    on Dec 31, 2023
  2. madsmtm commented on Jan 2, 2024

    @madsmtm
    Member

    has to do with the IME implementation

    Very likely.

    Thanks for the detailed investigation, I don't have the time to conjure up a fix this week, but might take a stab at it later (especially if reminded).

  3. added this to the Version 0.31.0 milestone on Jan 15, 2024
  4. HolgerGottChristensen commented on Jan 17, 2024

    @HolgerGottChristensen
    Author

    @madsmtm Here is your friendly reminder 😃

  5. 9mm commented on May 17, 2024

    @9mm

    Emojis definitely would be nice to have natively supported in popup

  6. andrewhannebrink commented on Jul 20, 2024

    @andrewhannebrink

    I love alacritty. If this issue gets fixed it would be a near perfect experience.

  7. chardskarth commented on Sep 26, 2024

    @chardskarth

    @madsmtm here's another friendly reminder. :D

    If I knew rust, I'd pick this up myself because both alacritty & neovide is working best for me right now.

  8. loliee commented on Feb 8, 2025

    @loliee

    Fixing this will make so many people happy 🥳

  9. added
    B - bug
    on Feb 24, 2025
  10. added 2 commits that reference this issue on Oct 9, 2025
    7b786c9
    a0c20a5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    B - bugDS - appkit

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions