Lines Matching defs: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
139 * Resets all meta state to inactive.
149 * Gets the state of the meta keys.
164 * Gets the state of a particular meta key.
210 * state will be reset to unshifted (if it is not still down)
221 * keep track of any meta state in the specified text.
230 * keep track of the selecting meta state in the specified text.
246 * Call this if you are a method that ignores the locked meta state
287 int state = content.getSpanFlags(what);
289 if (state == PRESSED)
291 else if (state == RELEASED)
293 else if (state == USED)
295 else if (state == LOCKED)
370 * Call this if you are a method that ignores the locked meta state
373 public static long resetLockedMeta(long state) {
374 if ((state & META_CAP_LOCKED) != 0) {
375 state &= ~META_SHIFT_MASK;
377 if ((state & META_ALT_LOCKED) != 0) {
378 state &= ~META_ALT_MASK;
380 if ((state & META_SYM_LOCKED) != 0) {
381 state &= ~META_SYM_MASK;
383 return state;
387 // Version of API that operates on a state bit mask
391 * Gets the state of the meta keys.
393 * @param state the current meta state bits.
398 public static final int getMetaState(long state) {
401 if ((state & META_CAP_LOCKED) != 0) {
403 } else if ((state & META_SHIFT_ON) != 0) {
407 if ((state & META_ALT_LOCKED) != 0) {
409 } else if ((state & META_ALT_ON) != 0) {
413 if ((state & META_SYM_LOCKED) != 0) {
415 } else if ((state & META_SYM_ON) != 0) {
423 * Gets the state of a particular meta key.
425 * @param state the current state bits.
430 public static final int getMetaState(long state, int meta) {
433 if ((state & META_CAP_LOCKED) != 0) return 2;
434 if ((state & META_SHIFT_ON) != 0) return 1;
438 if ((state & META_ALT_LOCKED) != 0) return 2;
439 if ((state & META_ALT_ON) != 0) return 1;
443 if ((state & META_SYM_LOCKED) != 0) return 2;
444 if ((state & META_SYM_ON) != 0) return 1;
454 * state will be reset to unshifted (if it is not still down)
456 * the current state, returns the new state.
458 public static long adjustMetaAfterKeypress(long state) {
459 if ((state & META_CAP_PRESSED) != 0) {
460 state = (state & ~META_SHIFT_MASK) | META_SHIFT_ON | META_CAP_USED;
461 } else if ((state & META_CAP_RELEASED) != 0) {
462 state &= ~META_SHIFT_MASK;
465 if ((state & META_ALT_PRESSED) != 0) {
466 state = (state & ~META_ALT_MASK) | META_ALT_ON | META_ALT_USED;
467 } else if ((state & META_ALT_RELEASED) != 0) {
468 state &= ~META_ALT_MASK;
471 if ((state & META_SYM_PRESSED) != 0) {
472 state = (state & ~META_SYM_MASK) | META_SYM_ON | META_SYM_USED;
473 } else if ((state & META_SYM_RELEASED) != 0) {
474 state &= ~META_SYM_MASK;
476 return state;
482 public static long handleKeyDown(long state, int keyCode, KeyEvent event) {
484 return press(state, META_SHIFT_ON, META_SHIFT_MASK,
490 return press(state, META_ALT_ON, META_ALT_MASK,
495 return press(state, META_SYM_ON, META_SYM_MASK,
498 return state;
501 private static long press(long state, int what, long mask,
503 if ((state & pressed) != 0) {
505 } else if ((state & released) != 0) {
506 state = (state &~ mask) | what | locked;
507 } else if ((state & used) != 0) {
509 } else if ((state & locked) != 0) {
510 state &= ~mask;
512 state |= what | pressed;
514 return state;
520 public static long handleKeyUp(long state, int keyCode, KeyEvent event) {
522 return release(state, META_SHIFT_ON, META_SHIFT_MASK,
528 return release(state, META_ALT_ON, META_ALT_MASK,
533 return release(state, META_SYM_ON, META_SYM_MASK,
536 return state;
539 private static long release(long state, int what, long mask,
543 if ((state & used) != 0) {
544 state &= ~mask;
545 } else if ((state & pressed) != 0) {
546 state |= what | released;
551 state &= ~mask;
554 return state;
558 * Clears the state of the specified meta key if it is locked.
559 * @param state the meta key state
563 public long clearMetaKeyState(long state, int which) {
564 if ((which & META_SHIFT_ON) != 0 && (state & META_CAP_LOCKED) != 0) {
565 state &= ~META_SHIFT_MASK;
567 if ((which & META_ALT_ON) != 0 && (state & META_ALT_LOCKED) != 0) {
568 state &= ~META_ALT_MASK;
570 if ((which & META_SYM_ON) != 0 && (state & META_SYM_LOCKED) != 0) {
571 state &= ~META_SYM_MASK;
573 return state;