mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 13:56:24 +02:00
generalized keyboard focus interface
Removed dynamic casts to RenderableWebEntityItem, instead virtual methods were added to EntityItem to facilitate this. * bool wantsKeyboardFocus() * void setProxyWindow() * QObject* getEventHandler()
This commit is contained in:
parent
4db1687746
commit
8bb6bb7c6f
4 changed files with 19 additions and 17 deletions
|
@ -2048,10 +2048,9 @@ bool Application::event(QEvent* event) {
|
|||
case QEvent::KeyRelease: {
|
||||
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
|
||||
auto entity = entityScriptingInterface->getEntityTree()->findEntityByID(_keyboardFocusedItem.get());
|
||||
RenderableWebEntityItem* webEntity = dynamic_cast<RenderableWebEntityItem*>(entity.get());
|
||||
if (webEntity && webEntity->getEventHandler()) {
|
||||
if (entity && entity->getEventHandler()) {
|
||||
event->setAccepted(false);
|
||||
QCoreApplication::sendEvent(webEntity->getEventHandler(), event);
|
||||
QCoreApplication::sendEvent(entity->getEventHandler(), event);
|
||||
if (event->isAccepted()) {
|
||||
_lastAcceptedKeyPress = usecTimestampNow();
|
||||
return true;
|
||||
|
@ -2931,10 +2930,9 @@ void Application::idle(float nsecsElapsed) {
|
|||
// update position of highlight overlay
|
||||
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
|
||||
auto entity = entityScriptingInterface->getEntityTree()->findEntityByID(_keyboardFocusedItem.get());
|
||||
RenderableWebEntityItem* webEntity = dynamic_cast<RenderableWebEntityItem*>(entity.get());
|
||||
if (webEntity && _keyboardFocusHighlight) {
|
||||
_keyboardFocusHighlight->setRotation(webEntity->getRotation());
|
||||
_keyboardFocusHighlight->setPosition(webEntity->getPosition());
|
||||
if (entity && _keyboardFocusHighlight) {
|
||||
_keyboardFocusHighlight->setRotation(entity->getRotation());
|
||||
_keyboardFocusHighlight->setPosition(entity->getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3540,9 +3538,8 @@ void Application::setKeyboardFocusEntity(EntityItemID entityItemID) {
|
|||
auto properties = entityScriptingInterface->getEntityProperties(entityItemID);
|
||||
if (EntityTypes::Web == properties.getType() && !properties.getLocked() && properties.getVisible()) {
|
||||
auto entity = entityScriptingInterface->getEntityTree()->findEntityByID(entityItemID);
|
||||
RenderableWebEntityItem* webEntity = dynamic_cast<RenderableWebEntityItem*>(entity.get());
|
||||
if (webEntity) {
|
||||
webEntity->setProxyWindow(_window->windowHandle());
|
||||
if (entity && entity->wantsKeyboardFocus()) {
|
||||
entity->setProxyWindow(_window->windowHandle());
|
||||
if (_keyboardMouseDevice->isActive()) {
|
||||
_keyboardMouseDevice->pluginFocusOutEvent();
|
||||
}
|
||||
|
@ -3560,9 +3557,9 @@ void Application::setKeyboardFocusEntity(EntityItemID entityItemID) {
|
|||
_keyboardFocusHighlight->setIgnoreRayIntersection(true);
|
||||
_keyboardFocusHighlight->setDrawInFront(false);
|
||||
}
|
||||
_keyboardFocusHighlight->setRotation(webEntity->getRotation());
|
||||
_keyboardFocusHighlight->setPosition(webEntity->getPosition());
|
||||
_keyboardFocusHighlight->setDimensions(webEntity->getDimensions() * 1.05f);
|
||||
_keyboardFocusHighlight->setRotation(entity->getRotation());
|
||||
_keyboardFocusHighlight->setPosition(entity->getPosition());
|
||||
_keyboardFocusHighlight->setDimensions(entity->getDimensions() * 1.05f);
|
||||
_keyboardFocusHighlight->setVisible(true);
|
||||
_keyboardFocusHighlightID = getOverlays().addOverlay(_keyboardFocusHighlight);
|
||||
}
|
||||
|
|
|
@ -32,8 +32,10 @@ public:
|
|||
virtual void render(RenderArgs* args) override;
|
||||
virtual void setSourceUrl(const QString& value) override;
|
||||
|
||||
void setProxyWindow(QWindow* proxyWindow);
|
||||
QObject* getEventHandler();
|
||||
virtual bool wantsHandControllerPointerEvents() const override { return true; }
|
||||
virtual bool wantsKeyboardFocus() const override { return true; }
|
||||
virtual void setProxyWindow(QWindow* proxyWindow) override;
|
||||
virtual QObject* getEventHandler() override;
|
||||
|
||||
void handlePointerEvent(const PointerEvent& event);
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <QtGui/QWindow>
|
||||
|
||||
#include <AnimationCache.h> // for Animation, AnimationCache, and AnimationPointer classes
|
||||
#include <Octree.h> // for EncodeBitstreamParams class
|
||||
#include <OctreeElement.h> // for OctreeElement::AppendState
|
||||
|
@ -435,6 +437,9 @@ public:
|
|||
virtual bool isTransparent() { return _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) < 1.0f : false; }
|
||||
|
||||
virtual bool wantsHandControllerPointerEvents() const { return false; }
|
||||
virtual bool wantsKeyboardFocus() const { return false; }
|
||||
virtual void setProxyWindow(QWindow* proxyWindow) {}
|
||||
virtual QObject* getEventHandler() { return nullptr; }
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -54,8 +54,6 @@ public:
|
|||
virtual void setSourceUrl(const QString& value);
|
||||
const QString& getSourceUrl() const;
|
||||
|
||||
virtual bool wantsHandControllerPointerEvents() const { return true; }
|
||||
|
||||
protected:
|
||||
QString _sourceUrl;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue