Pre loader

Mouse + Keyboard for ChartModifiers

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

Answered
2
0

Hi,
How can I get my application to do the following:

  • RubberBandXyZoomModifier execute on left mouse
  • ZoomPanModifier execute on left mouse + ctrl

I tried extending the ZoomPanModifier as such:

public class ZoomPanModifierEx : ZoomPanModifier
{
   public override void OnModifierMouseDown(ModifierMouseArgs e)
   {
      IsEnabled = (e.MouseButtons == MouseButtons.Left) && (e.Modifier == MouseModifier.Ctrl);
      base.OnModifierMouseDown(e);
   }
}

This did not work though.

Thanks in advance.

Johnny

  • You must to post comments
Best Answer
3
0

Hi Jonny,

Try testing Keyboard.Modifiers instead of e.Modifier to see if the CTRL key is pressed.

Then, try setting ExecuteOn=MouseLeftButton for the RubberBandXyZoomModifier.

Like this:

public class RubberBandXyZoomModifierEx : RubberBandXyZoomModifier
{
    public override void OnModifierMouseDown(ModifierMouseArgs e)
    {
        IsXAxisOnly = !e.IsMaster;

        if (!(Keyboard.Modifiers == ModifierKeys.Control))
        {
            base.OnModifierMouseDown(e);
        }
    }
}

public class ZoomPanModifierEx : ZoomPanModifier
{
    public override void OnModifierMouseDown(ModifierMouseArgs e)
    {
        if ((e.MouseButtons == MouseButtons.Left) && (Keyboard.Modifiers == ModifierKeys.Control))
        {
            base.OnModifierMouseDown(e);
        }
    }
}

Hope this helps!
Andrew

  • You must to post comments
1
0

Hi,

Hmm… It seems to me you should use “if” here instead:

public class ZoomPanModifierEx : ZoomPanModifier
{
   public override void OnModifierMouseDown(ModifierMouseArgs e)
   {
      if(e.MouseButtons == MouseButtons.Left) && (e.Modifier == MouseModifier.Ctrl)
      {
         base.OnModifierMouseDown(e);
      }
   }
}

Best regards,
Yuriy

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies