IT. Expert System.

Android Reference

MetaKeyKeyListener


android.text.method

Class MetaKeyKeyListener

  • Direct Known Subclasses:
    BaseKeyListener


    public abstract class MetaKeyKeyListener
    extends Object
    This base class encapsulates the behavior for tracking the state of meta keys such as SHIFT, ALT and SYM as well as the pseudo-meta state of selecting text.

    Key listeners that care about meta state should inherit from this class; you should not instantiate this class directly in a client.

    This class provides two mechanisms for tracking meta state that can be used together or independently.

    The behavior of this class varies according to the keyboard capabilities described by the KeyCharacterMap of the keyboard device such as the key modifier behavior.

    MetaKeyKeyListener implements chorded and toggled key modifiers. When key modifiers are toggled into a latched or locked state, the state of the modifier is stored in the Editable text buffer or in a meta state integer managed by the client. These latched or locked modifiers should be considered to be held in addition to those that the keyboard already reported as being pressed in KeyEvent.getMetaState(). In other words, the MetaKeyKeyListener augments the meta state provided by the keyboard; it does not replace it. This distinction is important to ensure that meta keys not handled by MetaKeyKeyListener such as KeyEvent.KEYCODE_CAPS_LOCK or KeyEvent.KEYCODE_NUM_LOCK are taken into consideration.

    To ensure correct meta key behavior, the following pattern should be used when mapping key codes to characters:

    private char getUnicodeChar(TextKeyListener listener, KeyEvent event, Editable textBuffer) { // Use the combined meta states from the event and the key listener. int metaState = event.getMetaState() | listener.getMetaState(textBuffer); return event.getUnicodeChar(metaState); }
    • Constructor Detail

      • MetaKeyKeyListener

        public MetaKeyKeyListener()
    • Method Detail

      • resetMetaState

        public static void resetMetaState(Spannable text)
        Resets all meta state to inactive.
      • getMetaState

        public static final int getMetaState(CharSequence text)
        Gets the state of the meta keys.
        Parameters:
        text - the buffer in which the meta key would have been pressed.
        Returns:
        an integer in which each bit set to one represents a pressed or locked meta key.
      • getMetaState

        public static final int getMetaState(CharSequence text,
                       int meta)
        Gets the state of a particular meta key.
        Parameters:
        meta - META_SHIFT_ON, META_ALT_ON, META_SYM_ON, or META_SELECTING
        text - the buffer in which the meta key would have been pressed.
        Returns:
        0 if inactive, 1 if active, 2 if locked.
      • adjustMetaAfterKeypress

        public static void adjustMetaAfterKeypress(Spannable content)
        Call this method after you handle a keypress so that the meta state will be reset to unshifted (if it is not still down) or primed to be reset to unshifted (once it is released).
      • isMetaTracker

        public static boolean isMetaTracker(CharSequence text,
                            Object what)
        Returns true if this object is one that this class would use to keep track of any meta state in the specified text.
      • isSelectingMetaTracker

        public static boolean isSelectingMetaTracker(CharSequence text,
                                     Object what)
        Returns true if this object is one that this class would use to keep track of the selecting meta state in the specified text.
      • resetLockedMeta

        protected static void resetLockedMeta(Spannable content)
        Call this if you are a method that ignores the locked meta state (arrow keys, for example) and you handle a key.
      • onKeyDown

        public boolean onKeyDown(View view,
                        Editable content,
                        int keyCode,
                        KeyEvent event)
        Handles presses of the meta keys.
      • startSelecting

        public static void startSelecting(View view,
                          Spannable content)
        Start selecting text.
      • onKeyUp

        public boolean onKeyUp(View view,
                      Editable content,
                      int keyCode,
                      KeyEvent event)
        Handles release of the meta keys.
      • clearMetaKeyState

        public void clearMetaKeyState(View view,
                             Editable content,
                             int states)
      • clearMetaKeyState

        public static void clearMetaKeyState(Editable content,
                             int states)
      • resetLockedMeta

        public static long resetLockedMeta(long state)
        Call this if you are a method that ignores the locked meta state (arrow keys, for example) and you handle a key.
      • getMetaState

        public static final int getMetaState(long state)
        Gets the state of the meta keys.
        Parameters:
        state - the current meta state bits.
        Returns:
        an integer in which each bit set to one represents a pressed or locked meta key.
      • getMetaState

        public static final int getMetaState(long state,
                       int meta)
        Gets the state of a particular meta key.
        Parameters:
        state - the current state bits.
        meta - META_SHIFT_ON, META_ALT_ON, or META_SYM_ON
        Returns:
        0 if inactive, 1 if active, 2 if locked.
      • adjustMetaAfterKeypress

        public static long adjustMetaAfterKeypress(long state)
        Call this method after you handle a keypress so that the meta state will be reset to unshifted (if it is not still down) or primed to be reset to unshifted (once it is released). Takes the current state, returns the new state.
      • handleKeyDown

        public static long handleKeyDown(long state,
                         int keyCode,
                         KeyEvent event)
        Handles presses of the meta keys.
      • handleKeyUp

        public static long handleKeyUp(long state,
                       int keyCode,
                       KeyEvent event)
        Handles release of the meta keys.
      • clearMetaKeyState

        public long clearMetaKeyState(long state,
                             int which)
        Clears the state of the specified meta key if it is locked.
        Parameters:
        state - the meta key state
        which - meta keys to clear, may be a combination of META_SHIFT_ON, META_ALT_ON or META_SYM_ON.


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 442 / . Delta: 0.02925 с