Skip to content

Commit

Permalink
focusing fix
Browse files Browse the repository at this point in the history
  • Loading branch information
voloko committed Jun 24, 2010
1 parent 3e4929d commit e550a36
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/core-examples/wave/wave.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ uki({ view: 'HSplitPane', id: 'splitMain', rect: '15 50 975 950', minSize: '800
{ view: 'Button', rect: '58 16 33 24', backgroundPrefix: 'plus-big-button-', anchors: 'left bottom', focusable: false }
] },
{ view: 'Toolbar', rect: '0 79 470 24', anchors: 'left top right', background: 'theme(toolbar-normal)', buttons: [
toolbarButton('Reply', '-128px 0'), toolbarButton('Playback', '-144px 0'), toolbarButton('Unfollow', '-16px 0'), toolbarButton('Archive', '-32px 0'), toolbarButton('Spam', '-48px 0'), toolbarButton('Read', '-64px 0'), toolbarButton('Unread', '-80px 0'), toolbarButton('Trash', '-96px 0'), toolbarButton('Move to', '-112px 0')
toolbarButton('Reply', '-128px 0'), toolbarButton('Playback', '-144px 0'), toolbarButton('Unfollow', '-16px 0'), toolbarButton('Archive', '-32px 0'), toolbarButton('Spam', '-48px 0'), toolbarButton('Read', '-64px 0'), toolbarButton('Unread', '-80px 0'), toolbarButton('Trash', '-96px 0'), toolbarButton('Move to', '-112px 0')
] },
{ view: 'Label', id: 'message', rect: '0 103 470 791', anchors: 'left top right bottom', multiline: true, scrollable: true, inset: '2 2', textSelectable: true },
{ view: 'Box', rect: '0 894 470 32', background: 'theme(box-lblue-bottom)', anchors: 'left bottom right', childViews: [
Expand Down
18 changes: 15 additions & 3 deletions src/uki-core/view/focusable.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,18 @@ uki.view.Focusable = new function() {/** @lends uki.view.Focusable.prototype */
this._firstFocus = true;

uki.dom.bind(this._focusTarget, 'focus', uki.proxy(function(e) {
this._stopWatingForBlur();
if (!this._hasFocus) this._focus(e);
}, this));

uki.dom.bind(this._focusTarget, 'blur', uki.proxy(function(e) {
if (this._hasFocus) {
this._hasFocus = false;
setTimeout(uki.proxy(function() { // wait for mousedown refocusing
if (!this._hasFocus) this._blur();
}, this), 1);
this._waitingForBlur =
setTimeout(uki.proxy(function() { // wait for mousedown refocusing
this._waitingForBlur = false;
if (!this._hasFocus) this._blur();
}, this), 1);
}
}, this));

Expand All @@ -79,8 +82,17 @@ uki.view.Focusable = new function() {/** @lends uki.view.Focusable.prototype */
this._hasFocus = false;
}

this._stopWatingForBlur = function() {
if (this._waitingForBlur) {
clearTimeout(this._waitingForBlur);
this._waitingForBlur = false;
this._hasFocus = true;
}
};

this.focus = function() {
if (this._focusable && !this._disabled) {
this._stopWatingForBlur();
if (!this._hasFocus) this._focus();
var target = this._focusTarget;
setTimeout(function() {
Expand Down

0 comments on commit e550a36

Please sign in to comment.