History

Initial IME support

ksuprynowicz committed 3 years ago

Commit 17dc2de1 parent ab219454 files · +47 −0Browse files

Showing the changes to interface/src/Application.cpp (1 of 4 files). Show all

Unified · Split

interface/src/Application.cpp+29−0
@@ -4181,6 +4181,31 @@ static inline bool isKeyEvent(QEvent::Type type) { · 4180 unmodified lines
41814181 return type == QEvent::KeyPress || type == QEvent::KeyRelease;
41824182 }
41834183
4184+bool Application::handleInputMethodEventForFocusedEntity(QEvent* event) {
4185+ if (_keyboardFocusedEntity.get() != UNKNOWN_ENTITY_ID) {
4186+ switch (event->type()) {
4187+ case QEvent::InputMethod:
4188+ case QEvent::InputMethodQuery:
4189+ {
4190+ auto eventHandler = getEntities()->getEventHandler(_keyboardFocusedEntity.get());
4191+ if (eventHandler) {
4192+ event->setAccepted(false);
4193+ QCoreApplication::sendEvent(eventHandler, event);
4194+ if (event->isAccepted()) {
4195+ _lastAcceptedKeyPress = usecTimestampNow();
4196+ return true;
4197+ }
4198+ }
4199+ break;
4200+ }
4201+ default:
4202+ break;
4203+ }
4204+ }
4205+
4206+ return false;
4207+}
4208+
41844209 bool Application::handleKeyEventForFocusedEntity(QEvent* event) {
41854210 if (_keyboardFocusedEntity.get() != UNKNOWN_ENTITY_ID) {
41864211 switch (event->type()) {
@@ -4241,6 +4266,10 @@ bool Application::event(QEvent* event) { · 54 unmodified lines
42414266 return false;
42424267 }
42434268
4269+ if ((event->type() == QEvent::InputMethod || event->type() == QEvent::InputMethodQuery) && handleInputMethodEventForFocusedEntity(event)) {
4270+ return true;
4271+ }
4272+
42444273 // Allow focused Entities to handle keyboard input
42454274 if (isKeyEvent(event->type()) && handleKeyEventForFocusedEntity(event)) {
42464275 return true;