home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Java / netscape / application / KeyEvent.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-04-12  |  4.2 KB  |  182 lines

  1. package netscape.application;
  2.  
  3. public class KeyEvent extends Event {
  4.    public int key;
  5.    public int modifiers;
  6.    public static final int KEY_DOWN = -11;
  7.    public static final int KEY_UP = -12;
  8.    public static final int NO_MODIFIERS_MASK = 0;
  9.    public static final int ALT_MASK = 8;
  10.    public static final int CONTROL_MASK = 2;
  11.    public static final int SHIFT_MASK = 1;
  12.    public static final int META_MASK = 4;
  13.    public static final int RETURN_KEY = 10;
  14.    public static final int BACKSPACE_KEY = 8;
  15.    public static final int DELETE_KEY = 127;
  16.    public static final int ESCAPE_KEY = 27;
  17.    public static final int TAB_KEY = 9;
  18.    public static final int UP_ARROW_KEY = 1004;
  19.    public static final int DOWN_ARROW_KEY = 1005;
  20.    public static final int LEFT_ARROW_KEY = 1006;
  21.    public static final int RIGHT_ARROW_KEY = 1007;
  22.    public static final int HOME_KEY = 1000;
  23.    public static final int END_KEY = 1001;
  24.    public static final int PAGE_UP_KEY = 1002;
  25.    public static final int PAGE_DOWN_KEY = 1003;
  26.    public static final int F1_KEY = 1008;
  27.    public static final int F2_KEY = 1009;
  28.    public static final int F3_KEY = 1010;
  29.    public static final int F4_KEY = 1011;
  30.    public static final int F5_KEY = 1012;
  31.    public static final int F6_KEY = 1013;
  32.    public static final int F7_KEY = 1014;
  33.    public static final int F8_KEY = 1015;
  34.    public static final int F9_KEY = 1016;
  35.    public static final int F10_KEY = 1017;
  36.    public static final int F11_KEY = 1018;
  37.    public static final int F12_KEY = 1019;
  38.  
  39.    public KeyEvent() {
  40.    }
  41.  
  42.    public KeyEvent(long var1, int var3, int var4, boolean var5) {
  43.       this();
  44.       super.timeStamp = var1;
  45.       if (var5) {
  46.          super.type = -11;
  47.       } else {
  48.          super.type = -12;
  49.       }
  50.  
  51.       this.key = var3;
  52.       this.modifiers = var4;
  53.    }
  54.  
  55.    public boolean isShiftKeyDown() {
  56.       return (this.modifiers & 1) != 0;
  57.    }
  58.  
  59.    public boolean isControlKeyDown() {
  60.       return (this.modifiers & 2) != 0;
  61.    }
  62.  
  63.    public boolean isMetaKeyDown() {
  64.       return (this.modifiers & 4) != 0;
  65.    }
  66.  
  67.    public boolean isAltKeyDown() {
  68.       return (this.modifiers & 8) != 0;
  69.    }
  70.  
  71.    public boolean isReturnKey() {
  72.       return this.key == 10;
  73.    }
  74.  
  75.    public boolean isBackspaceKey() {
  76.       return this.key == 8;
  77.    }
  78.  
  79.    public boolean isDeleteKey() {
  80.       return this.key == 127;
  81.    }
  82.  
  83.    public boolean isEscapeKey() {
  84.       return this.key == 27;
  85.    }
  86.  
  87.    public boolean isTabKey() {
  88.       return this.key == 9 && !this.isShiftKeyDown();
  89.    }
  90.  
  91.    public boolean isBackTabKey() {
  92.       return this.key == 9 && this.isShiftKeyDown();
  93.    }
  94.  
  95.    public boolean isUpArrowKey() {
  96.       return this.key == 1004;
  97.    }
  98.  
  99.    public boolean isDownArrowKey() {
  100.       return this.key == 1005;
  101.    }
  102.  
  103.    public boolean isLeftArrowKey() {
  104.       return this.key == 1006;
  105.    }
  106.  
  107.    public boolean isRightArrowKey() {
  108.       return this.key == 1007;
  109.    }
  110.  
  111.    public boolean isArrowKey() {
  112.       return this.key == 1004 || this.key == 1005 || this.key == 1006 || this.key == 1007;
  113.    }
  114.  
  115.    public boolean isHomeKey() {
  116.       return this.key == 1000;
  117.    }
  118.  
  119.    public boolean isEndKey() {
  120.       return this.key == 1001;
  121.    }
  122.  
  123.    public boolean isPageUpKey() {
  124.       return this.key == 1002;
  125.    }
  126.  
  127.    public boolean isPageDownKey() {
  128.       return this.key == 1003;
  129.    }
  130.  
  131.    public int isFunctionKey() {
  132.       if (this.key == 1008) {
  133.          return 1;
  134.       } else if (this.key == 1009) {
  135.          return 2;
  136.       } else if (this.key == 1010) {
  137.          return 3;
  138.       } else if (this.key == 1011) {
  139.          return 4;
  140.       } else if (this.key == 1012) {
  141.          return 5;
  142.       } else if (this.key == 1013) {
  143.          return 6;
  144.       } else if (this.key == 1014) {
  145.          return 7;
  146.       } else if (this.key == 1015) {
  147.          return 8;
  148.       } else if (this.key == 1016) {
  149.          return 9;
  150.       } else if (this.key == 1017) {
  151.          return 10;
  152.       } else if (this.key == 1018) {
  153.          return 11;
  154.       } else {
  155.          return this.key == 1019 ? 12 : 0;
  156.       }
  157.    }
  158.  
  159.    public boolean isPrintableKey() {
  160.       return this.key >= 32 && !this.isArrowKey() && !this.isHomeKey() && !this.isEndKey() && this.isFunctionKey() == 0;
  161.    }
  162.  
  163.    public void setRootView(RootView var1) {
  164.       super.processor = var1;
  165.    }
  166.  
  167.    public RootView rootView() {
  168.       return (RootView)super.processor;
  169.    }
  170.  
  171.    public String toString() {
  172.       String var1;
  173.       if (super.type == -11) {
  174.          var1 = "KeyDown";
  175.       } else {
  176.          var1 = "KeyUp";
  177.       }
  178.  
  179.       return this.key < 32 ? var1 + ":'' (0x" + Integer.toString(this.key, 16) + ")':" + this.modifiers : var1 + ":'" + (char)this.key + "' (0x" + Integer.toString(this.key, 16) + ")':" + this.modifiers;
  180.    }
  181. }
  182.