Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
1.6 KiB

  1. <PUBLIC:COMPONENT lightweight>
  2. <PUBLIC:PROPERTY name="selected" get="get_selected" put="put_selected"/>
  3. <PUBLIC:PROPERTY name=paddingWidth />
  4. <PUBLIC:PROPERTY name=borderWidth />
  5. <PUBLIC:ATTACH event="onmouseover" onevent="OnMouseOver();"/>
  6. <PUBLIC:ATTACH event="onmouseout" onevent="OnMouseOut();" />
  7. <PUBLIC:ATTACH event="onkeypress" onevent="OnKeyPress();" />
  8. <PUBLIC:ATTACH event="onkeydown" onevent="OnKeyDown();" />
  9. </PUBLIC:COMPONENT>
  10. <SCRIPT language="JavaScript">
  11. var _bSelected = false;
  12. var _nPadding = paddingWidth ? parseInt(paddingWidth) : 0;
  13. var _nBorder = borderWidth ? parseInt(borderWidth) : 1;
  14. function Hilite()
  15. {
  16. style.padding = _nPadding;
  17. style.borderWidth = _nBorder;
  18. }
  19. function Unhilite()
  20. {
  21. style.borderWidth = 0;
  22. style.padding = (_nPadding + _nBorder);
  23. }
  24. // Set the initial padding now
  25. Unhilite();
  26. function get_selected()
  27. {
  28. return _bSelected;
  29. }
  30. function put_selected(val)
  31. {
  32. if (val == true)
  33. {
  34. _bSelected = true;
  35. Hilite();
  36. }
  37. else
  38. {
  39. _bSelected = false;
  40. Unhilite();
  41. }
  42. }
  43. function OnMouseOver()
  44. {
  45. if (!_bSelected && !this.contains(event.fromElement) && this.contains(event.srcElement))
  46. Hilite();
  47. }
  48. function OnMouseOut()
  49. {
  50. if (!_bSelected && !this.contains(event.toElement))
  51. Unhilite();
  52. }
  53. function OnKeyPress()
  54. {
  55. // If it's Enter, click the element and stop the event
  56. // from bubbling so it doesn't go to the default button.
  57. if (event.keyCode == 13)
  58. {
  59. event.returnValue = false;
  60. event.srcElement.click();
  61. }
  62. }
  63. function OnKeyDown()
  64. {
  65. top.window.OnKeySelect(0, event);
  66. }
  67. </SCRIPT>