Overview

Gesture modifiers allow a gesture to only be activated -- or to never be activated -- if some condition holds true. An example from the default configuration is the use of the scroll wheel to switch between tabs in a web browser. In this example a modifier is applied specifying that the right button of the mouse must be held while the mouse wheel is being scrolled, if not the gesture will not be recognized. Alternatively, a modifier can be used to specify that a gesture should not be recognized if a modifier holds true. If we used this type of modifier the web browser would recognize the scroll wheel gesture only when the mouse's right button was not held.

Included Modifiers

  • Button Down - Modifies gestures based on the state of a button component.
  • Delayed Button Down - Modifies gestures after a button has been held for a fixed period of time.

Extending Modifiers

To create new modifiers inherit from the Modifier abstract class and decorate with the Modifier attribute. The IsActive method must be implemented and should return true if the conditions of the modifier are met. Any properties that should be set by the user should be marked with the UserProperty attribute. If a property is of a non-primitive type a property setter user control and property converter must be created.

Sample

[PartCreationPolicy(CreationPolicy.NonShared)]
[Modifier("ButtonDownModifier")]
public class ButtonDownModifier : Modifier
{
    [UserProperty]
    public ButtonDeviceComponent Button { get; set; }

    protected override Boolean IsActive()
    {
        if (Button == null)
            return false;

        return Button.State == ButtonState.Down;
    }
}

Last edited Nov 20, 2009 at 7:48 PM by PhilipB, version 3

Comments

No comments yet.