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.

70 lines
1.2 KiB

  1. <PUBLIC:COMPONENT>
  2. <PUBLIC:PROPERTY name="selected" get="get_selected" put="put_selected"/>
  3. <PUBLIC:ATTACH event="onmouseover" onevent="OnMouseOver();"/>
  4. <PUBLIC:ATTACH event="onmouseout" onevent="OnMouseOut();" />
  5. <PUBLIC:ATTACH event="onkeypress" onevent="OnKeyPress();" />
  6. <SCRIPT language="JavaScript">
  7. var _bSelected = false;
  8. function Hilite()
  9. {
  10. style.padding = '0';
  11. style.border = '1px solid highlight';
  12. }
  13. function Unhilite()
  14. {
  15. style.border = '';
  16. style.padding = '1px'
  17. }
  18. function get_selected()
  19. {
  20. return _bSelected;
  21. }
  22. function put_selected(val)
  23. {
  24. if (val == true)
  25. {
  26. _bSelected = true;
  27. Hilite();
  28. }
  29. else
  30. {
  31. _bSelected = false;
  32. Unhilite();
  33. }
  34. }
  35. function OnMouseOver()
  36. {
  37. if (!_bSelected && !this.contains(event.fromElement))
  38. Hilite();
  39. }
  40. function OnMouseOut()
  41. {
  42. if (!_bSelected && !this.contains(event.toElement))
  43. Unhilite();
  44. }
  45. function OnKeyPress()
  46. {
  47. // If it's Enter or Space, click the element and stop the event
  48. // from bubbling so Enter keys don't go to the default button.
  49. if (event.keyCode == 13 /*|| event.keyCode == 32*/)
  50. {
  51. event.returnValue = false;
  52. event.srcElement.click();
  53. }
  54. }
  55. </SCRIPT>
  56. </PUBLIC:COMPONENT>