Pre loader

Annotations onDrag callback function

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,

would it be possible for the onDrag function to return the same values as onClick, namely sender, mouseArgs, and relativeCoords (although I won’t need the latter)? Currently, it doesn’t return anything.

Best regards,
Kamil

Version
3.5.687
  • You must to post comments
1
0

Hello, this is an improvement we can potentially make in the future.
But first, please elaborate on the purpose you need this for and what is the feature you are trying to implement.

Or meanwhile, you can just override onDragAdorner method on an annotation to get those params:

  // pseudocode
  import {EventHandler, ModifierMouseArgs, DpiHelper, Point, ...} from "scichart"

   class CustomizedDraggableAnnotation extends SomeAnnotationClass {
    public customDragEventHandler: EventHandler<any> = new EventHandler<any>();

    public override onDragAdorner(args: ModifierMouseArgs): void {
        super.onDragAdorner(args);
        // add necessary logic here.
       // for example:
        const borders = this.getAdornerAnnotationBorders(true);
        const x = args.mousePoint.x / DpiHelper.PIXEL_RATIO;
        const y = args.mousePoint.y / DpiHelper.PIXEL_RATIO;
        const relativeCoords = new Point(x - borders.x1, y - borders.y1);
        this.customDragEventHandler.raiseEvent({args, sender: this, relativeCoords });
    }

    public override delete() {
        this.customDragEventHandler.unsubscribeAll()
        super.delete()
     }
   }

// ...
// usage:
const annotation = CustomizedDraggableAnnotation(...)
annotation.customDragEventHandler.subscribe(({args, sender, relativeCoords) => {...} )

Let us know if that worked for you.

  • You must to post comments
1
0

Thank you for the response! It works flawlessly. We need this because we are creating a special mode for creating/dragging annotations. The idea is that during the creation/dragging of, for example, a line, the y1 and y2 points must be located at the minimum or maximum price (candlestick chart). Therefore, I need the mouseArgs to check if the cursor is closer to the minimum or maximum, and sender to overwrite y1 and y2. We will be implementing this mode for every type of annotation.

  • You must to post comments
0
0

One more question, is it possible to get information on whether the user is dragging the line from the right/left side or if they are “holding” and dragging the entire line (body)?

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.