mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:58:11 +00:00
LibGUI+LibVT: Notify widgets of emoji selection with a callback
Currently, LibGUI modifies the Ctrl+Alt+Space key event to instead represent the emoji that was selected through EmojiInputDialog. This is limited to a single code point. For multiple code point emoji support, individual widgets now set a hook to be notified of the emoji selection with a UTF-8 encoded string. This replaces the previous set_accepts_emoji_input() method.
This commit is contained in:
parent
8190120f95
commit
31b2d93038
5 changed files with 33 additions and 16 deletions
|
@ -192,18 +192,14 @@ void ConnectionToWindowServer::key_down(i32 window_id, u32 code_point, u32 key,
|
|||
return;
|
||||
}
|
||||
|
||||
bool focused_widget_accepts_emoji_input = window->focused_widget() && window->focused_widget()->accepts_emoji_input();
|
||||
bool focused_widget_accepts_emoji_input = window->focused_widget() && window->focused_widget()->on_emoji_input;
|
||||
if (!window->blocks_emoji_input() && focused_widget_accepts_emoji_input && (modifiers == (Mod_Ctrl | Mod_Alt)) && key == Key_Space) {
|
||||
auto emoji_input_dialog = EmojiInputDialog::construct(window);
|
||||
if (emoji_input_dialog->exec() != EmojiInputDialog::ExecResult::OK)
|
||||
return;
|
||||
key_event->m_key = Key_Invalid;
|
||||
key_event->m_modifiers = 0;
|
||||
|
||||
Utf8View m_utf8_view(emoji_input_dialog->selected_emoji_text());
|
||||
u32 emoji_code_point = *m_utf8_view.begin();
|
||||
|
||||
key_event->m_code_point = emoji_code_point;
|
||||
window->focused_widget()->on_emoji_input(emoji_input_dialog->selected_emoji_text());
|
||||
return;
|
||||
}
|
||||
|
||||
bool accepts_command_palette = !window->blocks_command_palette();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue