Handling composed key for international text

26 views
Skip to first unread message

Gonzalo Garramuño

unread,
Aug 22, 2025, 4:03:25 PMAug 22
to fltkg...@googlegroups.com
I wrote a text input widget (NOT derived from Fl_Input or Fl_Input_ as
it is Vulkan based).  I need some help in knowing how to handle
international input.

For example, how to handle:

ó or ü

Currently, my input widget uses Fl::event_text and as such, it gets
twice the input.  That is both:

´ and ó

Can any of the developers point me to the location in the FLTK code
where composition keys are handled?

--
ggar...@gmail.com

Manolo

unread,
Aug 22, 2025, 4:33:05 PMAug 22
to fltk.general
Follow what the documentation of function Fl::compose(int&) says.

Gonzalo Garramuño

unread,
Aug 22, 2025, 5:10:23 PMAug 22
to fltkg...@googlegroups.com

El 22/8/25 a las 17:33, Manolo escribió:
> Follow what the documentation of function Fl::compose(int&) says.

Thanks, Manolo.  But I found the documentation on the web somewhat
confusing and also out of date (could not make it work so far). The C++
comments in my Github branch of FLTK 1.5 which also mention:

Fl::compose_state.

Can you point me to the code that uses these?  I am testing Wayland
input events at the moment if that matters.

--
ggar...@gmail.com

Manolo

unread,
Aug 23, 2025, 2:09:52 AMAug 23
to fltk.general
You are right Gonzalo, my previous post was inadequate.

Instructions given by the documentation of Fl::compose(int&) apply to the situation
where one creates a new widget that inputs text and wants to support dead keys,
composed characters, and even complex input methods such as those used for CJK.

But what you're asking is more: give text input support to a new FLTK platform.

I recommend you don't code something that would tie together the Vulkan code and your new 
text input widget, and rather work on two fronts:
1) give full text input support to the Vulkan platform;
2) have your text input widget call Fl::compose(), Fl::compose_reset(), fl_set_spot() and fl_reset_spot()
as described in the documentation.
With this, Vulkan should support all sorts of text input in Fl_Input, Fl_Text_Editor and your new widget.

There's no real documentation of what to do on front 1), only comments here and there
in platform-specific code. You may find inspiration in what Wayland does dealing with variables
Fl::compose_state and Fl_Wayland_Screen_Driver::next_marked_length in file Fl_Wayland_Screen_Driver.cxx.
Thus, you would have to implement these member functions:
- Fl_Vulkan_Screen_Driver::compose(int& del)
- Fl_Vulkan_Screen_Driver::compose_reset() 
- Fl_Vulkan_Screen_Driver::reset_spot()
- the Vulkan equivalent of wl_keyboard_key() that runs each time a key is pressed or released.
I also recommend you to use the xkb library that interfaces very cleanly a client program to
keyboard input operations.

Manolo

unread,
Aug 23, 2025, 2:55:52 AMAug 23
to fltk.general
Wait a minute. I'm getting confused here. Vulkan is not a full new FLTK platform.
It replaces what EGL does for the Wayland platform and runs inside a Wayland client.

Thus, Wayland will call wl_keyboard_key() at each keystroke. That function will compute
Fl::e_text and send FL_KEYBOARD events to your widget. It's your widget's job to draw 
the utf8 text received in Fl::event_text() adequately.

So, yes, all your widget has to do is follow what the documentation of functions
Fl::compose(), Fl::compose_reset(), fl_set_spot() and fl_reset_spot() say.


Gonzalo Garramuño

unread,
Aug 23, 2025, 4:00:06 AMAug 23
to fltkg...@googlegroups.com

El 23/8/25 a las 3:55, Manolo escribió:
>
> So, yes, all your widget has to do is follow what the documentation of
> functions
> Fl::compose(), Fl::compose_reset(), fl_set_spot() and fl_reset_spot() say.
>
Yes, I got it working.  What got me confused is that for compose keys,
there would be two FL_KEYBOARD events, one for Fl::compose(del) where
del != 0 and then one for the actual composed key.
It would be to clarify that in the Fl::compose() docs.

--
ggar...@gmail.com

Bill Spitzak

unread,
Aug 23, 2025, 12:42:40 PMAug 23
to fltkg...@googlegroups.com
I believe new systems are supporting the input methods, which can do the compose key itself. Would check into making sure that works. The fl_compose was just something to get an input method when there was no other way.


--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/fltkgeneral/ada3fd7b-5744-4f67-93df-24c692d0a854%40gmail.com.

Matthias Melcher

unread,
Aug 23, 2025, 12:53:41 PMAug 23
to fltk.general
„Compare“ originates from OS‘s that use several keystrokes to write one character. For example, the Germn ö has a key on the German keyboard (so it’s a single keystroke and Fl::event_text returns the correct utf8 sequence. But if you have a U.S. keyboard, you can type ö by compositing “ and o . On macOS the sequence is Alt-U followed by O. FLTK outputs the “ after the first keystroke, and on the second keystroke, compose deletes the previous character and instead generates the ö. 

This is pretty cool to watch when you compose Korean characters out of three keystrokes. fLTK „builds“ the finals glyph in three steps.

Reply all
Reply to author
Forward
0 new messages