save/restore focus.
This commit is contained in:
parent
5265275d0d
commit
e094f843db
|
@ -197,6 +197,8 @@ The screen on which every other node renders.
|
||||||
- **focusNext()** - focus next element in the index.
|
- **focusNext()** - focus next element in the index.
|
||||||
- **focusPush(element)** - push element on the focus stack (equivalent to `screen.focused = el`).
|
- **focusPush(element)** - push element on the focus stack (equivalent to `screen.focused = el`).
|
||||||
- **focusPop()/focusLast()** - pop element off the focus stack.
|
- **focusPop()/focusLast()** - pop element off the focus stack.
|
||||||
|
- **saveFocus()** - save the focused element.
|
||||||
|
- **restoreFocus()** - restore the saved focused element.
|
||||||
|
|
||||||
|
|
||||||
#### Element (from Node)
|
#### Element (from Node)
|
||||||
|
|
|
@ -675,6 +675,17 @@ Screen.prototype.focusPop = function() {
|
||||||
return this.history.pop();
|
return this.history.pop();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Screen.prototype.saveFocus = function() {
|
||||||
|
return this._savedFocus = this.focused;
|
||||||
|
};
|
||||||
|
|
||||||
|
Screen.prototype.restoreFocus = function() {
|
||||||
|
if (!this._savedFocus) return;
|
||||||
|
this._savedFocus.focus();
|
||||||
|
delete this._savedFocus;
|
||||||
|
return this.focused;
|
||||||
|
};
|
||||||
|
|
||||||
Screen.prototype.__defineGetter__('focused', function() {
|
Screen.prototype.__defineGetter__('focused', function() {
|
||||||
return this.history[this.history.length-1];
|
return this.history[this.history.length-1];
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue