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
4181 return type == QEvent::KeyPress || type == QEvent::KeyRelease;4181 return type == QEvent::KeyPress || type == QEvent::KeyRelease;
4182}4182}
4183 4183
4184bool 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
4184bool Application::handleKeyEventForFocusedEntity(QEvent* event) {4209bool Application::handleKeyEventForFocusedEntity(QEvent* event) {
4185 if (_keyboardFocusedEntity.get() != UNKNOWN_ENTITY_ID) {4210 if (_keyboardFocusedEntity.get() != UNKNOWN_ENTITY_ID) {
4186 switch (event->type()) {4211 switch (event->type()) {
@@ -4241,6 +4266,10 @@ bool Application::event(QEvent* event) { · 54 unmodified lines
4241 return false;4266 return false;
4242 }4267 }
4243 4268
4269 if ((event->type() == QEvent::InputMethod || event->type() == QEvent::InputMethodQuery) && handleInputMethodEventForFocusedEntity(event)) {
4270 return true;
4271 }
4272
4244 // Allow focused Entities to handle keyboard input4273 // Allow focused Entities to handle keyboard input
4245 if (isKeyEvent(event->type()) && handleKeyEventForFocusedEntity(event)) {4274 if (isKeyEvent(event->type()) && handleKeyEventForFocusedEntity(event)) {
4246 return true;4275 return true;