SDL icon indicating copy to clipboard operation
SDL copied to clipboard

Remove `SDL_HINT_IME_SUPPORT_EXTENDED_TEXT` and use `SDL_GetEventState` to enable/disable it instead

Open Susko3 opened this issue 3 years ago • 5 comments

Description

Removes the hint SDL_HINT_IME_SUPPORT_EXTENDED_TEXT. Instead applications can use SDL_EventState(SDL_TEXTEDITING_EXT, SDL_ENABLE) to enable extended text editing events.

Keep in mind that SDL_EventState needs to be called after SDL_Init, as the default value is set during initialisation.

I find it a bit strange that defaults for events get set in SDL_StartEventLoop. I would expect them to be set in SDL_EventsInit.

Existing Issue(s)

  • Discussed in https://github.com/libsdl-org/SDL/issues/6573#issuecomment-1325574683

Migration for those using SDL_HINT_IME_SUPPORT_EXTENDED_TEXT

-    /* Enable extended text editing events */
-    SDL_SetHint(SDL_HINT_IME_SUPPORT_EXTENDED_TEXT, "1");

     /* Initialize SDL */
     SDL_Init(...);

+    /* Enable extended text editing events */
+    SDL_EventState(SDL_TEXTEDITING_EXT, SDL_ENABLE);

Susko3 avatar Nov 24 '22 22:11 Susko3

Adding @icculus to review and make the appropriate change in sdl2-compat

slouken avatar Nov 24 '22 23:11 slouken

Please add an entry to docs/README-migration.txt documenting the change and how applications should be updated for it.

slouken avatar Nov 25 '22 18:11 slouken

Wouldn't it be better to just drop the non-extended version? I would argue that it isn't very useful (and changes behavior depending on the platform).

Guldoman avatar Nov 25 '22 20:11 Guldoman

Yes, we should probably rethink how the original event works and just fix that.

slouken avatar Nov 25 '22 20:11 slouken

Are string allocations a concern in SDL? SDL_TextEditingEvent has no allocation, the 32 byte buffer is plentiful for most usages.

Wouldn't it be better to just drop the non-extended version? I would argue that it isn't very useful (and changes behavior depending on the platform).

That could work too. But applications need to be careful to always SDL_Free the text, even if they're not handling / doing anything useful with the SDL_TextEditingEvents.

If this is the way forward, I would suggest that the regular SDL_TextInputEvent also be converted to use a dynamically allocated string, and not a fixed buffer. Currently it sends multiple events if the text is longer than 32 bytes thus breaking the expectation that one user input = one text event.

Susko3 avatar Dec 04 '22 22:12 Susko3

This hint is gone, so we don't need this PR anymore.

slouken avatar Feb 11 '24 16:02 slouken