AppKit: NSFormatter maxLength with Korean IME composition not applied consistently

Environment

  • macOS: Sequoia 15.x
  • AppKit: NSTextField + custom NSFormatter
  • Input: Korean IME

Description I set a formatter to allow only 1 character.
When typing with Korean IME, the field sometimes shows 2 characters while typing.

Question How should I handle this case? Should it be done in NSFormatter or in the field editor (NSTextView)?

**i've tried **

  1. Formatter-only (isPartialStringValid…) — still see composition phases where length appears > 1 and rejection leads to awkward UX / broken composition.

  2. Delegate + hasMarkedText (via field editor NSTextView) — clamp only when hasMarkedText == NO. Works better, but timing can still allow transient over-length during composition.

  3. Notification approach (NSControlTextDidChangeNotification) — similar limitations to (2); timing depends on field editor behavior.

AppKit: NSFormatter maxLength with Korean IME composition not applied consistently
 
 
Q