Why does Blender use the deprecated appkit component on macos?

Blender is still using the NSTextInput protocol marked as deprecation. This will cause the Chinese input method to be unusable, and the Chinese-like input method cannot be used. The old NSTextInput needs to be replaced with NSTextInputClient. Can the appkit text input framework be upgraded?

Bumping this thread to open a larger conversation on cutting old Mac lines out of the source, but if this is too off-topic I can start a new thread. The Blender website says that Blender supports Mac OS 10.13, but there’s some stuff in the code that is for much older distributions (10.6 or earlier).

I’m not very well versed in Mac Carbon vs. Cocoa, but it seems like the “GHOST hack” logic in creator.c could be removed. I saw @ideasman42 has a “TODO: Investigate” at the function declaration in GHOST_SystemCocoa.mm. I investigated a little and it’s related to an issue with launching in Carbon, although almost everything in the code is now Cocoa.

Removing all references from Carbon requires adding some key-codes from events.h and eliminating lines of old code. I’m able to comment out all of the logic affected by removing Carbon\Carbon.h and using CoreFoundation/CoreFoundation.h. I still have full functionality on my 2015 Mac running 10.15 Catalina. I think what’s happening is some duplicate functionality - for example, mouse clicks have getButton using a Carbon function and handleMouseEvent function using Cocoa functions.

There might be some edge cases I’m not aware of that make this code necessary. On the other hand, it may be too old to be relevant anymore. I don’t fully understand every piece of the GHOST interface so maybe I’m misunderstanding something.

Hi, I’m not on macOS, this sounds like a more general platform maintenance issue.

Patches to remove usage of Carbon or other cleanups are definitely welcome. Just no one has got around to working on that so far.

1 Like

I have sent a patch to update the protocol.

However, in order to use Chinese-like input methods, the methods in the NSTextInputClient protocol need to be implemented properly. These methods are only implemented for Accented characters such as è in the current Blender source code.

My patch also just updates the protocol, but does not implement the methods.

I hope that East Asian users who are familiar with macOS will implement these.

I have investigated this issue and will share my findings.

In order to solve this problem, the following needs to be implemented.

  1. Notification of start of input method.
    When using an input method, the default keyboard input should be turned off.
  • Default keyboard input:
    Keyboard -> Mac OS (keyDown) -> Ghost -> Window Manager

  • When using the input method:
    Keyboard -> Mac OS (keyDown) -> Input method -> Mac OS (setMarkedText, insertText) -> Ghost -> Window Manager

  1. Notifying that the text is being edited by the input method and Processing the strings sent by the OS.
    For setMarkedText, it is necessary to process the pre-edit string, and for insertText, it is necessary to process the post-edited string appropriately.
    Mac OS calls the pre-edit text the marked text.
    However Windows OS calls the pre-edit string the composition string and the post-edited string the result string.
    Therefore, each string is needed to be stored in the composite and result of GHOST_TEventImeData.

  2. Notifying the end of the input method
    After sending the post-edited string, it is necessary to notify Blender’s Ghost that the input method is finished and the default keyboard input should be turned on.

I’m starting to understand Cocoa Framework, so I’ll give it a try.