Pre loader

How to set the Mouse Cursor programatically

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

1
0

Hi.

I am evaluating the SciChart control – so far it looks very promising.

I have a FastHeatMapRenderableSeries that is analyzed and a FastLineRenderableSeries line is drawn through the chart.

The user needs to be able to correct the analysis, and this is done by “drawing” in the heatmap.

As far as I could tell, the ChartModifierBase gives med the necessary hooks to track the user’s mouse movements – but I would like to give some visual feedback by changing the cursor, for instance to Cursors.Pen (Cursors from the Microsoft namespace)

Is this possible? I would want to enable drawing when user presses Ctrl, the disable it when user releases Ctrl…

Version
v4.2.1
  • You must to post comments
0
0

Hi Espen,

This should be really easy. WPF itself gives a mechanism to change the cursor of a WPF UserControl, such as the SciChartSurface.

SciChartSurface.Cursor = Cursors.Pen;

For a way to do this using our ChartModifier API, you could create some code like this:

public class CursorChangeModifier : ChartModifierBase
{
    public override void OnModifierKeyDown(ModifierKeyArgs e)
    {
        base.OnModifierKeyDown(e);

        base.SetCursor(e.Modifier == MouseModifier.Ctrl ? Cursors.Pen : Cursors.Arrow);
    }
}

sciChartSurface.ChartModifier = new ModifierGroup(new CursorChangeModifier());

That should do it, it should now change cursor to Hand when you press the CTRL key and Arrow when you release it.

Note you will need to first click on the chart to give it focus or Key events won’t fire.

As for drawing, you will need to listen to OnModifierMouseDown, OnModifierMouseUp, OnModifierMouseMove, and then change the X,Y values in a XyDataSeries / FastLineRenderableSeries pair. You can do this inside a ChartModifier to allow ‘drawing’ on the chart.

Or, or more complex shapes drawing, note that ChartModifierBase.ModifierSurface is a canvas which accepts any WPF UIElement.

For more info about our ChartModifier API please see here. For any questions, please ask!

Best regards,
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.