mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 16:55:09 +00:00
LibGUI: Add a simple emoji input dialog activated by Ctrl+Alt+Space :^)
Widgets can now opt in to emoji input via set_accepts_emoji_input(). If the focused widget accepts emoji input, we'll pop up a simple dialog with all the available emojis as clickable buttons. You can press escape if you change your mind and don't want an emoji. This UI layout definitely will not scale as we add more emojis, but it works for the moment, and we can adapt it as we go. Pretty cool! :^)
This commit is contained in:
parent
1b78d9fa1f
commit
4173905198
5 changed files with 173 additions and 0 deletions
|
@ -33,6 +33,7 @@
|
|||
#include <LibGUI/Desktop.h>
|
||||
#include <LibGUI/DisplayLink.h>
|
||||
#include <LibGUI/DragOperation.h>
|
||||
#include <LibGUI/EmojiInputDialog.h>
|
||||
#include <LibGUI/Event.h>
|
||||
#include <LibGUI/Menu.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
|
@ -167,6 +168,17 @@ void WindowServerConnection::handle(const Messages::WindowClient::KeyDown& messa
|
|||
action->activate();
|
||||
return;
|
||||
}
|
||||
|
||||
bool focused_widget_accepts_emoji_input = window->focused_widget() && window->focused_widget()->accepts_emoji_input();
|
||||
if (focused_widget_accepts_emoji_input && (message.modifiers() == (Mod_Ctrl | Mod_Alt)) && message.key() == Key_Space) {
|
||||
auto emoji_input_dialog = EmojiInputDialog::construct(window);
|
||||
if (emoji_input_dialog->exec() != EmojiInputDialog::ExecOK)
|
||||
return;
|
||||
key_event->m_key = Key_Invalid;
|
||||
key_event->m_modifiers = 0;
|
||||
key_event->m_text = emoji_input_dialog->selected_emoji_text();
|
||||
}
|
||||
|
||||
Core::EventLoop::current().post_event(*window, move(key_event));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue