_FocusMixin.js 2.0 KB

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