diff --git a/examples/newEditEntities.js b/examples/newEditEntities.js index ef1be8fef9..f9f604afe8 100644 --- a/examples/newEditEntities.js +++ b/examples/newEditEntities.js @@ -215,6 +215,28 @@ var toolBar = (function () { Overlays.editOverlay(loadFileMenuItem, { visible: active }); } + + that.setActive = function(active) { + if (active != isActive) { + isActive = active; + if (!isActive) { + entityListTool.setVisible(false); + gridTool.setVisible(false); + grid.setEnabled(false); + propertiesTool.setVisible(false); + selectionManager.clearSelections(); + cameraManager.disable(); + } else { + cameraManager.enable(); + entityListTool.setVisible(true); + gridTool.setVisible(true); + propertiesTool.setVisible(true); + grid.setEnabled(true); + } + } + toolBar.selectTool(activeButton, active); + }; + var RESIZE_INTERVAL = 50; var RESIZE_TIMEOUT = 20000; var RESIZE_MAX_CHECKS = RESIZE_TIMEOUT / RESIZE_INTERVAL; @@ -290,21 +312,7 @@ var toolBar = (function () { clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y }); if (activeButton === toolBar.clicked(clickedOverlay)) { - isActive = !isActive; - if (!isActive) { - entityListTool.setVisible(false); - gridTool.setVisible(false); - grid.setEnabled(false); - propertiesTool.setVisible(false); - selectionManager.clearSelections(); - cameraManager.disable(); - } else { - cameraManager.enable(); - entityListTool.setVisible(true); - gridTool.setVisible(true); - grid.setEnabled(true); - propertiesTool.setVisible(true); - } + that.setActive(!isActive); return true; } @@ -817,6 +825,13 @@ function handeMenuEvent(menuItem) { Menu.menuItemEvent.connect(handeMenuEvent); +Controller.keyPressEvent.connect(function(event) { + if (event.text == 'w' || event.text == 'a' || event.text == 's' || event.text == 'd' + || event.text == 'UP' || event.text == 'DOWN' || event.text == 'LEFT' || event.text == 'RIGHT') { + toolBar.setActive(false); + } +}); + Controller.keyReleaseEvent.connect(function (event) { // since sometimes our menu shortcut keys don't work, trap our menu items here also and fire the appropriate menu items if (event.text == "`") {