Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 0 Toggle panels shortcut not properly working #648

Merged
merged 7 commits into from
Dec 6, 2022
24 changes: 12 additions & 12 deletions src/components/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,17 @@ export default class Main extends React.Component {
}
} else if (event.which === 'attributes') {
this.setState(prevState => ({
visible: {
visible: Object.assign({}, prevState.visible, {
attributes: !prevState.visible.attributes
}
})
}));
} else if (event.which === 'scenegraph') {
this.setState(prevState => ({
visible: {
visible: Object.assign({}, prevState.visible, {
scenegraph: !prevState.visible.scenegraph
}
})
}));
}

this.forceUpdate();
});
}

Expand Down Expand Up @@ -109,15 +107,18 @@ export default class Main extends React.Component {
};

renderComponentsToggle() {
if (!this.state.entity || this.state.visible.attributes) {
if (
!this.state.inspectorEnabled ||
!this.state.entity ||
this.state.visible.attributes
) {
return null;
}
return (
<div className="toggle-sidebar right">
<a
onClick={() => {
this.setState({ visible: { attributes: true } });
this.forceUpdate();
Events.emit('togglesidebar', { which: 'attributes' });
}}
className="fa fa-plus"
title="Show components"
Expand All @@ -127,15 +128,14 @@ export default class Main extends React.Component {
}

renderSceneGraphToggle() {
if (this.state.visible.scenegraph) {
if (!this.state.inspectorEnabled || this.state.visible.scenegraph) {
return null;
}
return (
<div className="toggle-sidebar left">
<a
onClick={() => {
this.setState({ visible: { scenegraph: true } });
this.forceUpdate();
Events.emit('togglesidebar', { which: 'scenegraph' });
}}
className="fa fa-plus"
title="Show scenegraph"
Expand Down
6 changes: 3 additions & 3 deletions src/lib/shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ var Shortcuts = {
this.disable();
}

window.addEventListener('keydown', this.onKeyDown.bind(this), false);
window.addEventListener('keyup', this.onKeyUp.bind(this), false);
window.addEventListener('keydown', this.onKeyDown, false);
window.addEventListener('keyup', this.onKeyUp, false);
this.enabled = true;
},
disable: function() {
Expand All @@ -188,7 +188,7 @@ var Shortcuts = {
this.shortcuts.modules[moduleName][keyCode]
) {
console.warn(
'Keycode <%s> already registered as shorcut within the same module',
'Keycode <%s> already registered as shortcut within the same module',
keyCode
);
}
Expand Down
14 changes: 8 additions & 6 deletions src/style/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,6 @@ body.aframe-inspector-opened
position absolute
z-index 9998

.left
left 0

.right
right 0

a
background-color #262626
color #bcbcbc
Expand All @@ -262,3 +256,11 @@ body.aframe-inspector-opened
a.hover
background-color #1faaf2
color #fff

.toggle-sidebar.left
top 0
left 0

.toggle-sidebar.right
top 0
right 0