Skip to content

[0.31-beta.2] Disabling IME is broken on macOS #4432

@nicoburns

Description

@nicoburns

Description

On macOS ImeRequest::Disable is implemented as:

ImeRequest::Disable => {
    self.view().set_ime_allowed(None);
    return Ok(());
},

However the set_ime_allowed function is defined as:

pub(super) fn set_ime_allowed(&self, capabilities: Option<ImeCapabilities>) {
    if self.ivars().ime_capabilities.get().is_some() {
        return;
    }
    self.ivars().ime_capabilities.set(capabilities);

    if capabilities.is_some() {
        return;
    }

    // Clear markedText
    *self.ivars().marked_text.borrow_mut() = NSMutableAttributedString::new();

    if self.ivars().ime_state.get() != ImeState::Disabled {
        self.ivars().ime_state.set(ImeState::Disabled);
        self.queue_event(WindowEvent::Ime(Ime::Disabled));
    }
}

The guard at the very top of this function means that calling this function has no effect if IME is enabled (the macos backend appears to track this by whether the ime_capabilities is Some or None)

macOS version

macOS 15.6.1 (but OS version is unlikely to be relevant)

Winit version

0.31-beta.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    B - bugDang, that shouldn't have happenedDS - appkitAffects the AppKit/macOS backend

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions