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
- Kamil Macura asked 1 week ago
- You must login to post comments
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.
- Jim Risen answered 1 week ago
- last edited 1 week ago
- You must login to post comments
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.
- Kamil Macura answered 1 week ago
- You must login to post comments
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)?
- Kamil Macura answered 21 hours ago
- You must login to post comments
Please login first to submit.