共用方式為


KeyEvent.MetaStateHasModifiers(MetaKeyStates, MetaKeyStates) Method

Definition

Returns true if only the specified modifier keys are pressed according to the specified meta state.

[Android.Runtime.Register("metaStateHasModifiers", "(II)Z", "")]
public static bool MetaStateHasModifiers (Android.Views.MetaKeyStates metaState, Android.Views.MetaKeyStates modifiers);
[<Android.Runtime.Register("metaStateHasModifiers", "(II)Z", "")>]
static member MetaStateHasModifiers : Android.Views.MetaKeyStates * Android.Views.MetaKeyStates -> bool

Parameters

metaState
MetaKeyStates

The meta state to consider.

modifiers
MetaKeyStates

The meta state of the modifier keys to check. May be a combination of modifier meta states as defined by #getModifierMetaStateMask(). May be 0 to ensure that no modifier keys are pressed.

Returns

True if only the specified modifier keys are pressed.

Attributes

Exceptions

if the modifiers parameter contains invalid modifiers

Remarks

Returns true if only the specified modifier keys are pressed according to the specified meta state. Returns false if a different combination of modifier keys are pressed.

For the purposes of this function, #KEYCODE_CAPS_LOCK, #KEYCODE_SCROLL_LOCK, and #KEYCODE_NUM_LOCK are not considered modifier keys. Consequently, this function ignores #META_CAPS_LOCK_ON, #META_SCROLL_LOCK_ON and #META_NUM_LOCK_ON.

If the specified modifier mask includes directional modifiers, such as #META_SHIFT_LEFT_ON, then this method ensures that the modifier is pressed on that side. If the specified modifier mask includes non-directional modifiers, such as #META_SHIFT_ON, then this method ensures that the modifier is pressed on either side. If the specified modifier mask includes both directional and non-directional modifiers for the same type of key, such as #META_SHIFT_ON and #META_SHIFT_LEFT_ON, then this method throws an illegal argument exception.

Java documentation for android.view.KeyEvent.metaStateHasModifiers(int, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also