History

more work on clicking focus

ZappoMan committed 11 years ago

Commit b7d9dc41 parent 8cf450c5 files · +33 −10Browse files

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

Unified · Split

interface/src/Application.cpp+20−10
@@ -673,12 +673,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 672 unmodified lines
673 auto& packetReceiver = nodeList->getPacketReceiver();673 auto& packetReceiver = nodeList->getPacketReceiver();
674 packetReceiver.registerListener(PacketType::DomainConnectionDenied, this, "handleDomainConnectionDeniedPacket");674 packetReceiver.registerListener(PacketType::DomainConnectionDenied, this, "handleDomainConnectionDeniedPacket");
675 675
676 // If the user clicks an an entity, we will check that it's an unlocked web entity, and if so, set the focus to it
676 auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();677 auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
677 connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickDownOnEntity, 678 connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickDownOnEntity,
678 [this, entityScriptingInterface](const EntityItemID& entityItemID, const MouseEvent& event) {679 [this, entityScriptingInterface](const EntityItemID& entityItemID, const MouseEvent& event) {
679 if (_keyboardFocusedItem != entityItemID) {680 if (_keyboardFocusedItem != entityItemID) {
680 _keyboardFocusedItem = UNKNOWN_ENTITY_ID;681 _keyboardFocusedItem = UNKNOWN_ENTITY_ID;
681 qDebug() << "_keyboardFocusedItem:" << UNKNOWN_ENTITY_ID;682 qDebug() << "clickDownOnEntity.... _keyboardFocusedItem:" << UNKNOWN_ENTITY_ID;
682 auto properties = entityScriptingInterface->getEntityProperties(entityItemID);683 auto properties = entityScriptingInterface->getEntityProperties(entityItemID);
683 if (EntityTypes::Web == properties.getType() && !properties.getLocked()) {684 if (EntityTypes::Web == properties.getType() && !properties.getLocked()) {
684 auto entity = entityScriptingInterface->getEntityTree()->findEntityByID(entityItemID);685 auto entity = entityScriptingInterface->getEntityTree()->findEntityByID(entityItemID);
@@ -686,21 +687,19 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 1 unmodified line
686 if (webEntity) {687 if (webEntity) {
687 webEntity->setProxyWindow(_window->windowHandle());688 webEntity->setProxyWindow(_window->windowHandle());
688 _keyboardFocusedItem = entityItemID;689 _keyboardFocusedItem = entityItemID;
689 qDebug() << "_keyboardFocusedItem:" << entityItemID;690 _lastAcceptedKeyPress = usecTimestampNow();
691 qDebug() << "clickDownOnEntity.... _keyboardFocusedItem:" << entityItemID;
690 }692 }
691 }693 }
692 }694 }
693 });695 });
694 696
695 /*697 // If the user clicks somewhere where there is NO entity at all, we will release focus
696 // FIXME - need a solution for unfocusing on delayed time698 connect(getEntities(), &EntityTreeRenderer::mousePressOffEntity,
697 connect(entityScriptingInterface.data(), &EntityScriptingInterface::hoverLeaveEntity, [=](const EntityItemID& entityItemID, const MouseEvent& event) {699 [=](const RayToEntityIntersectionResult& entityItemID, const QMouseEvent* event, unsigned int deviceId) {
698 if (_keyboardFocusedItem == entityItemID) {700 _keyboardFocusedItem = UNKNOWN_ENTITY_ID;
699 _keyboardFocusedItem = UNKNOWN_ENTITY_ID;701 qDebug() << "mousePressOffEntity... _keyboardFocusedItem:" << UNKNOWN_ENTITY_ID;
700 qDebug() << "_keyboardFocusedItem:" << UNKNOWN_ENTITY_ID;
701 }
702 });702 });
703 */
704}703}
705 704
706void Application::aboutToQuit() {705void Application::aboutToQuit() {
@@ -1277,6 +1276,7 @@ bool Application::event(QEvent* event) { · 570 unmodified lines
1277 event->setAccepted(false);1276 event->setAccepted(false);
1278 QCoreApplication::sendEvent(webEntity->getEventHandler(), event);1277 QCoreApplication::sendEvent(webEntity->getEventHandler(), event);
1279 if (event->isAccepted()) {1278 if (event->isAccepted()) {
1279 _lastAcceptedKeyPress = usecTimestampNow();
1280 return true;1280 return true;
1281 }1281 }
1282 }1282 }
@@ -1286,6 +1286,16 @@ bool Application::event(QEvent* event) { · 3 unmodified lines
1286 default:1286 default:
1287 break;1287 break;
1288 }1288 }
1289
1290 const quint64 LOSE_FOCUS_AFTER_ELAPSED_TIME = 30 * USECS_PER_SECOND; // if idle for 30 seconds, drop focus
1291 quint64 elapsedSinceAcceptedKeyPress = usecTimestampNow() - _lastAcceptedKeyPress;
1292 if (elapsedSinceAcceptedKeyPress > LOSE_FOCUS_AFTER_ELAPSED_TIME) {
1293 _keyboardFocusedItem = UNKNOWN_ENTITY_ID;
1294 qDebug() << "idle for 30 seconds.... _keyboardFocusedItem:" << UNKNOWN_ENTITY_ID;
1295 } else {
1296 qDebug() << "elapsedSinceAcceptedKeyPress:" << elapsedSinceAcceptedKeyPress;
1297 }
1298
1289 }1299 }
1290 1300
1291 switch (event->type()) {1301 switch (event->type()) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t