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