[483] | 1 | define([ |
---|
| 2 | "./focus", |
---|
| 3 | "./_WidgetBase", |
---|
| 4 | "dojo/_base/declare", // declare |
---|
| 5 | "dojo/_base/lang" // lang.extend |
---|
| 6 | ], function(focus, _WidgetBase, declare, lang){ |
---|
| 7 | |
---|
| 8 | // module: |
---|
| 9 | // dijit/_FocusMixin |
---|
| 10 | |
---|
| 11 | // We don't know where _FocusMixin will occur in the inheritance chain, but we need the _onFocus()/_onBlur() below |
---|
| 12 | // to be last in the inheritance chain, so mixin to _WidgetBase. |
---|
| 13 | lang.extend(_WidgetBase, { |
---|
| 14 | // focused: [readonly] Boolean |
---|
| 15 | // This widget or a widget it contains has focus, or is "active" because |
---|
| 16 | // it was recently clicked. |
---|
| 17 | focused: false, |
---|
| 18 | |
---|
| 19 | onFocus: function(){ |
---|
| 20 | // summary: |
---|
| 21 | // Called when the widget becomes "active" because |
---|
| 22 | // it or a widget inside of it either has focus, or has recently |
---|
| 23 | // been clicked. |
---|
| 24 | // tags: |
---|
| 25 | // callback |
---|
| 26 | }, |
---|
| 27 | |
---|
| 28 | onBlur: function(){ |
---|
| 29 | // summary: |
---|
| 30 | // Called when the widget stops being "active" because |
---|
| 31 | // focus moved to something outside of it, or the user |
---|
| 32 | // clicked somewhere outside of it, or the widget was |
---|
| 33 | // hidden. |
---|
| 34 | // tags: |
---|
| 35 | // callback |
---|
| 36 | }, |
---|
| 37 | |
---|
| 38 | _onFocus: function(){ |
---|
| 39 | // summary: |
---|
| 40 | // This is where widgets do processing for when they are active, |
---|
| 41 | // such as changing CSS classes. See onFocus() for more details. |
---|
| 42 | // tags: |
---|
| 43 | // protected |
---|
| 44 | this.onFocus(); |
---|
| 45 | }, |
---|
| 46 | |
---|
| 47 | _onBlur: function(){ |
---|
| 48 | // summary: |
---|
| 49 | // This is where widgets do processing for when they stop being active, |
---|
| 50 | // such as changing CSS classes. See onBlur() for more details. |
---|
| 51 | // tags: |
---|
| 52 | // protected |
---|
| 53 | this.onBlur(); |
---|
| 54 | } |
---|
| 55 | }); |
---|
| 56 | |
---|
| 57 | return declare("dijit._FocusMixin", null, { |
---|
| 58 | // summary: |
---|
| 59 | // Mixin to widget to provide _onFocus() and _onBlur() methods that |
---|
| 60 | // fire when a widget or its descendants get/lose focus |
---|
| 61 | |
---|
| 62 | // flag that I want _onFocus()/_onBlur() notifications from focus manager |
---|
| 63 | _focusManager: focus |
---|
| 64 | }); |
---|
| 65 | |
---|
| 66 | }); |
---|