Added Pro Tip 2

This commit is contained in:
Jono Brandel 2011-02-14 13:34:27 -08:00
parent c189ae7f16
commit ae5ccdd736
2 changed files with 38 additions and 1 deletions

37
gui.js
View File

@ -451,8 +451,22 @@ var GUI = function() {
GUI.allGuis.push(this);
// Add hide listener if this is the first GUI.
if (GUI.allGuis.length == 1) {
window.addEventListener('keyup', function(e) {
// Hide on "H"
if (e.keyCode == 72) {
GUI.toggleHide();
}
}, false);
}
};
// Do not set this directly.
GUI.hidden = false;
// Static members
GUI.autoPlace = true;
@ -460,6 +474,29 @@ GUI.autoPlaceContainer = null;
GUI.allControllers = [];
GUI.allGuis = [];
GUI.toggleHide = function() {
if (GUI.hidden) {
GUI.show();
} else {
GUI.hide();
}
}
GUI.show = function() {
GUI.hidden = false;
for (var i in GUI.allGuis) {
GUI.allGuis[i].domElement.style.display = "block";
}
}
GUI.hide = function() {
GUI.hidden = true;
for (var i in GUI.allGuis) {
GUI.allGuis[i].domElement.style.display = "none";
}
}
GUI.saveURL = function() {
var url = GUI.replaceGetVar("saveString", GUI.getSaveString());
window.location = url;

View File

@ -319,7 +319,7 @@ document.getElementById("my-gui-container").appendChild( gui.domElement );</pre>
<ol id="secrets">
<li><strong>gui-dat</strong> panels are resizeable. Drag the show/hide button.</li>
<li>Pro tip #2 forthcoming.</li>
<li>Press 'H' to show/hide GUI&apos;s.</li>
</ol>
</div>
</div>