X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fui%2Fwebui%2Fresources%2Fjs%2Fcr%2Fui%2Ffocus_row.js;h=26c4c5567e2b673f24b19574c2b35afe6c69263f;hb=1afa4dd80ef85af7c90efaea6959db1d92330844;hp=d259d0aaea6261e5843451a149fa02df1e9dff32;hpb=90762837333c13ccf56f2ad88e4481fc71e8d281;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/ui/webui/resources/js/cr/ui/focus_row.js b/src/ui/webui/resources/js/cr/ui/focus_row.js index d259d0a..26c4c55 100644 --- a/src/ui/webui/resources/js/cr/ui/focus_row.js +++ b/src/ui/webui/resources/js/cr/ui/focus_row.js @@ -56,7 +56,7 @@ cr.define('cr.ui', function() { if (item != document.activeElement) item.tabIndex = -1; - this.eventTracker_.add(item, 'click', this.onClick_.bind(this)); + this.eventTracker_.add(item, 'mousedown', this.onMousedown_.bind(this)); }, this); /** @@ -75,9 +75,17 @@ cr.define('cr.ui', function() { * Called when a key is pressed while an item in |this.items| is focused. If * |e|'s default is prevented, further processing is skipped. * @param {cr.ui.FocusRow} row The row that detected a keydown. - * @param {Event} e The keydown event. + * @param {Event} e + * @return {boolean} Whether the event was handled. */ onKeydown: assertNotReached, + + /** + * @param {cr.ui.FocusRow} row The row that detected the mouse going down. + * @param {Event} e + * @return {boolean} Whether the event was handled. + */ + onMousedown: assertNotReached, }; /** @interface */ @@ -144,7 +152,7 @@ cr.define('cr.ui', function() { * @private */ onFocusin_: function(e) { - if (this.boundary_.contains(e.target)) + if (this.boundary_.contains(assertInstanceof(e.target, Node))) this.activeIndex = this.items.indexOf(e.target); }, @@ -157,10 +165,7 @@ cr.define('cr.ui', function() { if (item < 0) return; - if (this.delegate_) - this.delegate_.onKeydown(this, e); - - if (e.defaultPrevented) + if (this.delegate_ && this.delegate_.onKeydown(this, e)) return; var index = -1; @@ -185,7 +190,10 @@ cr.define('cr.ui', function() { * @param {Event} e A click event. * @private */ - onClick_: function(e) { + onMousedown_: function(e) { + if (this.delegate_ && this.delegate_.onMousedown(this, e)) + return; + if (!e.button) this.activeIndex = this.items.indexOf(e.currentTarget); },