Removed dynamic casts to RenderableWebEntityItem, instead virtual methods were added to EntityItem to facilitate this. * bool wantsKeyboardFocus() * void setProxyWindow() * QObject* getEventHandler()
Showing the changes to interface/src/Application.cpp (1 of 4 files). Show all
Unified · Split
| @@ -2048,10 +2048,9 @@ bool Application::event(QEvent* event) { · 2047 unmodified lines | |||
| 2048 | case QEvent::KeyRelease: { | 2048 | case QEvent::KeyRelease: { |
| 2049 | auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); | 2049 | auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); |
| 2050 | auto entity = entityScriptingInterface->getEntityTree()->findEntityByID(_keyboardFocusedItem.get()); | 2050 | auto entity = entityScriptingInterface->getEntityTree()->findEntityByID(_keyboardFocusedItem.get()); |
| 2051 | RenderableWebEntityItem* webEntity = dynamic_cast<RenderableWebEntityItem*>(entity.get()); | 2051 | if (entity && entity->getEventHandler()) { |
| 2052 | if (webEntity && webEntity->getEventHandler()) { | ||
| 2053 | event->setAccepted(false); | 2052 | event->setAccepted(false); |
| 2054 | QCoreApplication::sendEvent(webEntity->getEventHandler(), event); | 2053 | QCoreApplication::sendEvent(entity->getEventHandler(), event); |
| 2055 | if (event->isAccepted()) { | 2054 | if (event->isAccepted()) { |
| 2056 | _lastAcceptedKeyPress = usecTimestampNow(); | 2055 | _lastAcceptedKeyPress = usecTimestampNow(); |
| 2057 | return true; | 2056 | return true; |
| @@ -2931,10 +2930,9 @@ void Application::idle(float nsecsElapsed) { · 873 unmodified lines | |||
| 2931 | // update position of highlight overlay | 2930 | // update position of highlight overlay |
| 2932 | auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); | 2931 | auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); |
| 2933 | auto entity = entityScriptingInterface->getEntityTree()->findEntityByID(_keyboardFocusedItem.get()); | 2932 | auto entity = entityScriptingInterface->getEntityTree()->findEntityByID(_keyboardFocusedItem.get()); |
| 2934 | RenderableWebEntityItem* webEntity = dynamic_cast<RenderableWebEntityItem*>(entity.get()); | 2933 | if (entity && _keyboardFocusHighlight) { |
| 2935 | if (webEntity && _keyboardFocusHighlight) { | 2934 | _keyboardFocusHighlight->setRotation(entity->getRotation()); |
| 2936 | _keyboardFocusHighlight->setRotation(webEntity->getRotation()); | 2935 | _keyboardFocusHighlight->setPosition(entity->getPosition()); |
| 2937 | _keyboardFocusHighlight->setPosition(webEntity->getPosition()); | ||
| 2938 | } | 2936 | } |
| 2939 | } | 2937 | } |
| 2940 | } | 2938 | } |
| @@ -3540,9 +3538,8 @@ void Application::setKeyboardFocusEntity(EntityItemID entityItemID) { · 599 unmodified lines | |||
| 3540 | auto properties = entityScriptingInterface->getEntityProperties(entityItemID); | 3538 | auto properties = entityScriptingInterface->getEntityProperties(entityItemID); |
| 3541 | if (EntityTypes::Web == properties.getType() && !properties.getLocked() && properties.getVisible()) { | 3539 | if (EntityTypes::Web == properties.getType() && !properties.getLocked() && properties.getVisible()) { |
| 3542 | auto entity = entityScriptingInterface->getEntityTree()->findEntityByID(entityItemID); | 3540 | auto entity = entityScriptingInterface->getEntityTree()->findEntityByID(entityItemID); |
| 3543 | RenderableWebEntityItem* webEntity = dynamic_cast<RenderableWebEntityItem*>(entity.get()); | 3541 | if (entity && entity->wantsKeyboardFocus()) { |
| 3544 | if (webEntity) { | 3542 | entity->setProxyWindow(_window->windowHandle()); |
| 3545 | webEntity->setProxyWindow(_window->windowHandle()); | ||
| 3546 | if (_keyboardMouseDevice->isActive()) { | 3543 | if (_keyboardMouseDevice->isActive()) { |
| 3547 | _keyboardMouseDevice->pluginFocusOutEvent(); | 3544 | _keyboardMouseDevice->pluginFocusOutEvent(); |
| 3548 | } | 3545 | } |
| @@ -3560,9 +3557,9 @@ void Application::setKeyboardFocusEntity(EntityItemID entityItemID) { · 11 unmodified lines | |||
| 3560 | _keyboardFocusHighlight->setIgnoreRayIntersection(true); | 3557 | _keyboardFocusHighlight->setIgnoreRayIntersection(true); |
| 3561 | _keyboardFocusHighlight->setDrawInFront(false); | 3558 | _keyboardFocusHighlight->setDrawInFront(false); |
| 3562 | } | 3559 | } |
| 3563 | _keyboardFocusHighlight->setRotation(webEntity->getRotation()); | 3560 | _keyboardFocusHighlight->setRotation(entity->getRotation()); |
| 3564 | _keyboardFocusHighlight->setPosition(webEntity->getPosition()); | 3561 | _keyboardFocusHighlight->setPosition(entity->getPosition()); |
| 3565 | _keyboardFocusHighlight->setDimensions(webEntity->getDimensions() * 1.05f); | 3562 | _keyboardFocusHighlight->setDimensions(entity->getDimensions() * 1.05f); |
| 3566 | _keyboardFocusHighlight->setVisible(true); | 3563 | _keyboardFocusHighlight->setVisible(true); |
| 3567 | _keyboardFocusHighlightID = getOverlays().addOverlay(_keyboardFocusHighlight); | 3564 | _keyboardFocusHighlightID = getOverlays().addOverlay(_keyboardFocusHighlight); |
| 3568 | } | 3565 | } |