How to show an octothorpe ('#') on a keyboard with recolor enabled


I am using a custom keyboard widget with recoloring enabled. Since the recolor symbol is the ‘#’ character, enabling the recolor feature causes the ‘#’ character to not be displayed on the symbols keyboard and also on the ‘1#’ button (only the ‘1’ is displayed). Is there a way to correct this?

What MCU/Processor/Board and compiler are you using?

Windows Simulator and BeagleBone Black

What do you want to achieve?

Be able to show ‘#’ character on a colorized keyboard.

What have you tried so far?

Tried using all sorts of escape sequences on the ‘#’ key but am not able to get the ‘#’ to display. Appears to be an issue in the parsing code in lv_draw_label (LV_TXT_COLOR_CMD). I can modify the lvgl source to change the definition of LV_TXT_COLOR_CMD but would obviously prefer a better solution!

Code to reproduce

The code block(s) should be formatted like:

   lv_obj_t* pKeyboard = lv_kb_create(pParent, NULL);
   lv_kb_set_mode(pKeyboard, LV_KB_MODE_TEXT);
   lv_btnm_set_map(pKeyboard, kb_map_spec);
   lv_btnm_set_ctrl_map(pKeyboard, kb_ctrl_spec_map);
   lv_btnm_set_recolor(pKeyboard, true);

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

Can i see your keyboard map? Maybe # needs a control character.

It’s impossible to do in version 6.0 without modifying lv_txt.h and changing the value of LV_TXT_COLOR_CMD.

In version 6.1, we could allow customization of LV_TXT_COLOR_CMD in lv_conf.h. That way you could choose a different character to use.

That’s a great idea to make it customizable.

Can I have permission to break the rules and add that to 6.1, even though there’s a feature freeze? :slightly_smiling_face:

Sure :slight_smile: It’s a so minor change.

1 Like

LV_TXT_COLOR_CMD has been moved to lv_conf.h in dev-6.1, so you can change the control character to some other character not being used.

1 Like