Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Typically, standard mouse operators use a single mouse button. This article show how to setup an operator that uses two mouse buttons. Additionally, it describes creating a custom mouse operator which is triggered by two mouse buttons, if you needed other customizations.

...

Here are the steps to achieve and use a custom mouse operator;

  1. In this example, we’ll customize the standard HPS::PanOperator so that both the Left and the Right mouse buttons are required to use the pan operator. Here’s the custom class;

    Code Block
    public class MyPanOperator : HPS.PanOperator
    {
        public MyPanOperator() 
            : base(HPS.MouseButtons.ButtonLeft(), new HPS.ModifierKeys())
        {}
        ~MyPanOperator(){}
        public override bool OnMouseDown(HPS.MouseState iMouseState)
        {
           return iMouseState.GetButtons().Right() && base.OnMouseDown(iMouseState);
        }
        public override bool OnMouseMove(HPS.MouseState iMouseState)
        {
            return iMouseState.GetButtons().Right() && base.OnMouseMove(iMouseState);
        }
        public override bool OnMouseUp(HPS.MouseState iMouseState)
        {
            return iMouseState.GetButtons().Right() && base.OnMouseUp(iMouseState);
        }
    }
  2. Notice that the OnMouse* methods first check the state of the Right button and then use the base class to finish (and check the state of the Left button).

  3. Next we’ll set up a set of operators as follows;

    Code Block
    view.GetOperatorControl()
        .Push(new HPS.ZoomOperator(HPS.MouseButtons.ButtonMiddle()))
        .Push(new MyPanOperator(), Operator.Priority.High)
        .Push(new HPS.OrbitOperator(HPS.MouseButtons.ButtonRight()))
        .Push(new HPS.HighlightOperator(HPS.MouseButtons.ButtonLeft()),HPS.Operator.Priority.Low);
  •  Notice that since the custom pan operator requires two buttons, it needs the High priority so the other operators don’t steal the event with less restrictive requirements (i.e. only one button).

...

Filter by label (Content by label)
kb-how-to-article
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@2318a5
showSpacefalse
sortmodified
typeshowSpacepagefalse
reversetruelabels
typepage
cqllabel in ( "kb-how-to-article" , "mouse" , "operator" , "custom" ) and type = "page" and space = "KBHV"
labelskb-how-to-article
Page Properties
hiddentrue

Related issues

Jira Legacy
serverId43f371d0-7091-3b3c-9683-94c0b791358d
keySDHV-10195