Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: client/touch/EventUtil.dart

Issue 9382027: Move client/{base, observable, layout, touch, util, view} to samples/ui_lib . (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « client/touch/ClickBuster.dart ('k') | client/touch/FxUtil.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * Common events related helpers.
7 */
8 class EventUtil {
9
10 /**
11 * Add an event listener to an element.
12 * The event callback is specified by [handler].
13 * If [capture] is true, the listener gets events on the capture phase.
14 * If [removeHandlerOnFocus] is true the handler is removed when there is any
15 * focus event, and added back on blur events.
16 */
17 static void observe(Element element,
18 EventListenerList listenerList, Function handler,
19 [bool capture = false, bool removeHandlerOnFocus = false]) {
20 listenerList.add(handler, capture);
21 // TODO(jacobr): this remove on focus behavior seems really ugly.
22 if (removeHandlerOnFocus) {
23 element.on.focus.add((e) { listenerList.remove(handler, capture); });
24 element.on.blur.add((e) { listenerList.add(handler, capture); });
25 }
26 }
27
28 /**
29 * Clear the keyboard focus of the currently focused element (if there is
30 * one). If there is no currently focused element then this function will do
31 * nothing. For most browsers this will cause the keyboard to be dismissed.
32 */
33 static void blurFocusedElement() {
34 Element focusedEl = document.query("*:focus");
35 if (focusedEl != null) {
36 focusedEl.blur();
37 }
38 }
39 }
OLDNEW
« no previous file with comments | « client/touch/ClickBuster.dart ('k') | client/touch/FxUtil.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698