Lines Matching refs:state

28  * This base class encapsulates the behavior for tracking the state of
29 * meta keys such as SHIFT, ALT and SYM as well as the pseudo-meta state of selecting text.
31 * Key listeners that care about meta state should inherit from this class;
34 * This class provides two mechanisms for tracking meta state that can be used
39 * {@link #getMetaState(long)} operate on a meta key state bit mask.</li>
41 * {@link #getMetaState(CharSequence, int)} operate on meta key state flags stored
43 * meta key state of the text editor; they do not carry any positional information.</li>
51 * When key modifiers are toggled into a latched or locked state, the state
53 * meta state integer managed by the client. These latched or locked modifiers
56 * In other words, the {@link MetaKeyKeyListener} augments the meta state
142 * Resets all meta state to inactive.
152 * Gets the state of the meta keys.
167 * Gets the state of the meta keys for a specific key event.
169 * For input devices that use toggled key modifiers, the `toggled' state
170 * is stored into the text buffer. This method retrieves the meta state
171 * for this event, accounting for the stored state. If the event has been
173 * a virtual device for example, the stored state is ignored.
176 * @param event the event for which to evaluate the meta state.
192 * Gets the state of a particular meta key.
219 * Gets the state of a particular meta key to use with a particular key event.
222 * key modifiers, like a virtual keyboard for example, only the meta state in
227 * @param event the event for which to evaluate the meta state.
269 * state will be reset to unshifted (if it is not still down)
280 * keep track of any meta state in the specified text.
289 * keep track of the selecting meta state in the specified text.
305 * Call this if you are a method that ignores the locked meta state
346 int state = content.getSpanFlags(what);
348 if (state == PRESSED)
350 else if (state == RELEASED)
352 else if (state == USED)
354 else if (state == LOCKED)
429 * Call this if you are a method that ignores the locked meta state
432 public static long resetLockedMeta(long state) {
433 if ((state & META_CAP_LOCKED) != 0) {
434 state &= ~META_SHIFT_MASK;
436 if ((state & META_ALT_LOCKED) != 0) {
437 state &= ~META_ALT_MASK;
439 if ((state & META_SYM_LOCKED) != 0) {
440 state &= ~META_SYM_MASK;
442 return state;
446 // Version of API that operates on a state bit mask
450 * Gets the state of the meta keys.
452 * @param state the current meta state bits.
457 public static final int getMetaState(long state) {
460 if ((state & META_CAP_LOCKED) != 0) {
462 } else if ((state & META_SHIFT_ON) != 0) {
466 if ((state & META_ALT_LOCKED) != 0) {
468 } else if ((state & META_ALT_ON) != 0) {
472 if ((state & META_SYM_LOCKED) != 0) {
474 } else if ((state & META_SYM_ON) != 0) {
482 * Gets the state of a particular meta key.
484 * @param state the current state bits.
489 public static final int getMetaState(long state, int meta) {
492 if ((state & META_CAP_LOCKED) != 0) return LOCKED_RETURN_VALUE;
493 if ((state & META_SHIFT_ON) != 0) return PRESSED_RETURN_VALUE;
497 if ((state & META_ALT_LOCKED) != 0) return LOCKED_RETURN_VALUE;
498 if ((state & META_ALT_ON) != 0) return PRESSED_RETURN_VALUE;
502 if ((state & META_SYM_LOCKED) != 0) return LOCKED_RETURN_VALUE;
503 if ((state & META_SYM_ON) != 0) return PRESSED_RETURN_VALUE;
513 * state will be reset to unshifted (if it is not still down)
515 * the current state, returns the new state.
517 public static long adjustMetaAfterKeypress(long state) {
518 if ((state & META_CAP_PRESSED) != 0) {
519 state = (state & ~META_SHIFT_MASK) | META_SHIFT_ON | META_CAP_USED;
520 } else if ((state & META_CAP_RELEASED) != 0) {
521 state &= ~META_SHIFT_MASK;
524 if ((state & META_ALT_PRESSED) != 0) {
525 state = (state & ~META_ALT_MASK) | META_ALT_ON | META_ALT_USED;
526 } else if ((state & META_ALT_RELEASED) != 0) {
527 state &= ~META_ALT_MASK;
530 if ((state & META_SYM_PRESSED) != 0) {
531 state = (state & ~META_SYM_MASK) | META_SYM_ON | META_SYM_USED;
532 } else if ((state & META_SYM_RELEASED) != 0) {
533 state &= ~META_SYM_MASK;
535 return state;
541 public static long handleKeyDown(long state, int keyCode, KeyEvent event) {
543 return press(state, META_SHIFT_ON, META_SHIFT_MASK,
549 return press(state, META_ALT_ON, META_ALT_MASK,
554 return press(state, META_SYM_ON, META_SYM_MASK,
557 return state;
560 private static long press(long state, int what, long mask,
562 if ((state & pressed) != 0) {
564 } else if ((state & released) != 0) {
565 state = (state &~ mask) | what | locked;
566 } else if ((state & used) != 0) {
568 } else if ((state & locked) != 0) {
569 state &= ~mask;
571 state |= what | pressed;
573 return state;
579 public static long handleKeyUp(long state, int keyCode, KeyEvent event) {
581 return release(state, META_SHIFT_ON, META_SHIFT_MASK,
587 return release(state, META_ALT_ON, META_ALT_MASK,
592 return release(state, META_SYM_ON, META_SYM_MASK,
595 return state;
598 private static long release(long state, int what, long mask,
602 if ((state & used) != 0) {
603 state &= ~mask;
604 } else if ((state & pressed) != 0) {
605 state |= what | released;
610 state &= ~mask;
613 return state;
617 * Clears the state of the specified meta key if it is locked.
618 * @param state the meta key state
622 public long clearMetaKeyState(long state, int which) {
623 if ((which & META_SHIFT_ON) != 0 && (state & META_CAP_LOCKED) != 0) {
624 state &= ~META_SHIFT_MASK;
626 if ((which & META_ALT_ON) != 0 && (state & META_ALT_LOCKED) != 0) {
627 state &= ~META_ALT_MASK;
629 if ((which & META_SYM_ON) != 0 && (state & META_SYM_LOCKED) != 0) {
630 state &= ~META_SYM_MASK;
632 return state;