SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

0
0

Hi, there.

Our users want CreateAnnotationModifier be active while Control button is pressed. Also they want to delete selected annotation with delete button.

I add handlers for

sciChartSurface.KeyDown
sciChartSurface.KeyUp
sciChartSurface.GotFocus
sciChartSurface.GotMouseCapture
sciChartSurface.PreviewKeyDown

When control capture mouse it can do not recieve focus, thereby button events do not handle.
I am not sure but when control has focus it can not handle button events too.

Chart start handle button events when I am select annotation and click on chart after it.

It is impossible to manually call Focus(), because application has other controls.

When I am delete or add annotation chart loss and recieve focus many times.

Is this correct behaviour?

What additional information do you need for fixing this issue?

  • You must to post comments
1
0

Hi Kiril,

there is built-in way to achieve that with modifiers. You need to extend existing AnnotationCreationModifier, and check ModifierMouseArgs.Modifier for keyboards modifiers:

    public class AnnotationCreationModifierEx: AnnotationCreationModifier
    {
        public override void OnModifierMouseUp(ModifierMouseArgs mouseButtonEventArgs)
        {
            if (
                //checks for the first point
                (mouseButtonEventArgs.Modifier == MouseModifier.Ctrl && (Annotation == null || Annotation.IsSelected)) ||
                //checks for the second point
                (Annotation != null && !Annotation.IsSelected))
            {

                //fix for another issue, which appears if Y axis is left-aligned,
                //you may omit it
                var translatedPoint = GetPointRelativeTo(mouseButtonEventArgs.MousePoint, ModifierSurface);
                mouseButtonEventArgs.MousePoint = translatedPoint;

                //call base implementation
                base.OnModifierMouseUp(mouseButtonEventArgs);
            }
        }
    }

Please, try the above and give us any feedback.

Best regards,
Yuriy

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.