Mouse drag event available for art objects?

I want to receive event as user drag an art object so I can continuously monitor its position on the artboard.
Anyone know how to do this? Thanks so much.

You can take a look at the multiarrowtool in adobes sample code. That should give you the code required. These two functions allow for you to get the mouse postion.
ASErr MultiArrowToolPlugin::AddAnnotator(SPInterfaceMessage *message)
ASErr result = kNoErr;
 try
result = sAIAnnotator->AddAnnotator(message->d.self,"MultiArrowTool Annotator", &fAnnotatorHandle);aisdk::check_ai_error(result);
result = sAIAnnotator->SetAnnotatorActive(fAnnotatorHandle,
false);aisdk::check_ai_error(result);
catch (ai::Error& ex){
result = ex;
catch(...){
result = kCantHappenErr;
return result;}
*/ASErr MultiArrowToolPlugin::DrawAnnotator(AIAnnotatorMessage* message)
ASErr result = kNoErr;
 try
 // Invalid previous annotator.
result = sAIAnnotator->InvalAnnotationRect(NULL, &oldAnnotatorRect);
 // Get the string to display in annotator.
ai::UnicodeString pointStr;
 //result = this->GetPointString(fEndPoint, pointStr);
result =this->GetPointString(fStartingPoint, pointStr);aisdk::check_ai_error(result);
AIPoint annotatorPoint;
result = sAIDocumentView->ArtworkPointToViewPoint(NULL, &fEndPoint, &annotatorPoint);
// Move 5 points right and 5 points up.
annotatorPoint.h += 5;
annotatorPoint.v -= 5;
 // Find cursor bound rect.
AIRect annotatorRect;
result = sAIAnnotatorDrawer->GetTextBounds(message->drawer, pointStr, &annotatorPoint, annotatorRect);
aisdk::check_ai_error(result);
 //Draw a filled rectangle, the following R, G and B values combined makes light yellow.
 unsigned short red = 65000; 
unsigned short green = 65000; 
unsigned short blue = 40000;ADMRGBColor yellowFill = {red, green, blue};
sAIAnnotatorDrawer->SetColor(message->drawer, yellowFill);
result = sAIAnnotatorDrawer->DrawRect(message->drawer, annotatorRect,
true);aisdk::check_ai_error(result);
//Draw black outline, 0 for R, G and B makes black.
 unsigned short black = 0;ADMRGBColor blackFill = {black, black, black};
sAIAnnotatorDrawer->SetColor(message->drawer, blackFill);
sAIAnnotatorDrawer->SetLineWidth(message->drawer, 0.5);
result = sAIAnnotatorDrawer->DrawRect(message->drawer, annotatorRect,
false);aisdk::check_ai_error(result);
// Draw cursor text.
result = sAIAnnotatorDrawer->SetFontPreset(message->drawer, kAIAFSmall);
aisdk::check_ai_error(result);
result = sAIAnnotatorDrawer->DrawTextAligned(message->drawer, pointStr, kAICenter, kAIMiddle, annotatorRect);
aisdk::check_ai_error(result);
 // Save old rect
oldAnnotatorRect = annotatorRect;
 catch (ai::Error& ex){
result = ex;
return result;}
*/ASErr MultiArrowToolPlugin::GetPointString(const AIRealPoint& point, ai::UnicodeString& pointStr){
ASErr result = kNoErr;
try
ASInt32 precision = 2;
ai::UnicodeString horiz, vert;
ai::NumberFormat numFormat;
horiz = numFormat.toString((float) point.h, precision, horiz);vert = numFormat.toString((
float) -point.v, precision, vert);pointStr.append(ai::UnicodeString(
"h: ").append(horiz)
.append(ai::UnicodeString(
", v: ").append(vert)));
catch (ai::Error& ex){
result = ex;
return result;}

Similar Messages

  • Mouse dragged event with unexpected coordinates

    I am dragging the mouse on a half circle from the middle left to the top middle. This results in mouse events with the coordinates form (10,90) ->(100,10)
    Letting the mouse go and then dragging it further to the left, the coordinates in the of the event are similar than the starting point of the first mouse drag event.
    Can anyone shed some light on this peculiar behavior?

    First of, I have to apologize for the example not being as minimalistic as it might be, but on the plus side, I know now why this happens, I just don't know how to work around it.
    * To change this license header, choose License Headers in Project Properties.
    * To change this template file, choose Tools | Templates
    * and open the template in the editor.
    package javafxtest;
    import java.util.ArrayList;
    import javafx.application.Application;
    import javafx.beans.property.DoubleProperty;
    import javafx.beans.property.SimpleDoubleProperty;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.geometry.Dimension2D;
    import javafx.geometry.Point2D;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.Label;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.StackPane;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.Circle;
    import javafx.scene.shape.Polygon;
    import javafx.scene.shape.Rectangle;
    import javafx.scene.shape.Shape;
    import javafx.scene.transform.Rotate;
    import javafx.stage.Stage;
    * @author andi
    public class HandleRotation extends Application {
        private DoubleProperty currentRotation;
        private ArrayList<Double> angles;
        @Override
        public void start(Stage primaryStage) {
            currentRotation = new SimpleDoubleProperty(this, "currentRotation", 10);
            SteeringWheelGroup background = new SteeringWheelGroup(200);
            background.setManaged(false);
            Group g = new Group(background);
            final Point2D centerPoint = new Point2D(100, 100);
            angles = new ArrayList<>(3);
            angles.add(190.0);
            angles.add(270.0);
            angles.add(350.0);
            double step = (180.0 - 2 * currentRotation.doubleValue()) / (angles.size() - 1);
            int radius = 100;
            final int yTranslation = 15; // might be due to the labels
            Polygon handle = createHandle(centerPoint, radius, yTranslation);
            g.getChildren().add(handle);
            StackPane root = new StackPane();
            Scene scene = new Scene(g, 300, 250);
            primaryStage.setTitle("Handle Rotation!");
            primaryStage.setScene(scene);
            primaryStage.show();
         * Calculate the base point for the label. This is the point on the arc, matching the angle.
         * @param center point of the circle
         * @param radius radius of the circle
         * @param angle in degree in [0,180]
         * @return Point on the circle
        Point2D calculateBasePoint(Point2D center, double radius,
                double angle) {
            float newX = (float) (center.getX() + radius * Math.cos(Math.toRadians(angle)));
            float newY = (float) (center.getY() + radius * Math.sin(Math.toRadians(angle)));
            return new Point2D(newX, newY);
         * Create the polygon that represents the handle
         * @param centerPoint
         * @param radius
         * @return
        private Polygon createHandle(final Point2D centerPoint, int radius, final int yTranslation) {
            double baseAngle = 180;
            Point2D p1 = calculateBasePoint(centerPoint, radius, baseAngle - 5);
            Point2D p2 = calculateBasePoint(centerPoint, radius, baseAngle + 2);
            Point2D p3 = calculateBasePoint(centerPoint, radius*0.65, baseAngle + 2);
            Point2D p4 = calculateBasePoint(centerPoint, radius*0.65, baseAngle - 7);
            double[] points = {p1.getX(), p1.getY(), p2.getX(), p2.getY(), p3.getX(), p3.getY(), p4.getX(), p4.getY()};
                      Polygon polygon = new Polygon(points);
    //        polygon.setOpacity(0);
            polygon.setTranslateY(-yTranslation);
            final Rotate rotationTransform = new Rotate(currentRotation.doubleValue(), centerPoint.getX(), centerPoint.getY());
            polygon.getTransforms().add(rotationTransform);
            polygon.setOnMouseDragged(new EventHandler<MouseEvent>() {
                @Override
                public void handle(MouseEvent event) {
                    if (event.getY() < centerPoint.getY()) {
    System.out.println("Event: "+event);                   
                                                       Point2D point = new Point2D((float)event.getX(), (float)event.getY());
                        double newAngle = angleBetween2Lines(centerPoint, point);
                        if (newAngle < 0) {
                            newAngle = (90 + newAngle)+ 90;
    System.out.println("Set angle on mouse drag: "+newAngle);
                        if (newAngle < 10) {
                            newAngle = 10;
                        if (newAngle > 170) {
                            newAngle = 170;
                        currentRotation.set(newAngle);
            polygon.setOnMouseReleased(new EventHandler<MouseEvent>() {
                @Override
                public void handle(MouseEvent event) {
                    snapToNearestAngle();
                    rotationTransform.setAngle(currentRotation.doubleValue());
            return polygon;
         * Snap to the correct angle. Correct angle is angle belonging to the nearest label.
        void snapToNearestAngle() {
            double currentAngle = currentRotation.doubleValue() + 180;
            double currentMin = 360;
            int minIndex = 0;
    System.out.println("Current rotation is "+currentAngle);
            for (int i = 0; i < angles.size(); i++) {
                double angle = angles.get(i);
                double diff = Math.abs(angle - currentAngle);
                if (diff < currentMin) {
                    currentMin = diff;
                    minIndex = i;
    System.out.println("new minDifference at "+i+": "+diff);
            Double destinationAngle = angles.get(minIndex);
    System.out.println("DestinationAngle is "+currentAngle+" -> "+(destinationAngle - 180));
            if (destinationAngle < 180 + 10 || destinationAngle > 360 - 10) {
                throw new IllegalStateException("Angle is out of range: "+currentRotation.doubleValue()+" -> "+destinationAngle);
            currentRotation.set(destinationAngle - 180);
         * Calculate the angle between the vector horizontally to the left from the center
         * and the current point.
         * @param center point
         * @param point current point
         * @return angle in degree
        double angleBetween2Lines(Point2D center, Point2D point) {
            double slope2 = calculateSlope(center, point);
            double angle = Math.atan(slope2);
            if (point.getX() > center.getX()) {
                angle += Math.PI/2;
    System.out.println("Slope: "+slope2+" angle "+Math.toDegrees(angle));
            return Math.abs(Math.toDegrees(angle));
         * Caluculate the slope of the line defined by two points.
         * The first point is the center of a circle and the second
         * point roughly lies on the circle.
         * @param center point
         * @param point on the circle
         * @return slope of the connecting line.
        double calculateSlope(Point2D center, Point2D point) {
    System.out.println("center="+center+",point="+point);       
            double absSlope = Math.abs((point.getY() - center.getY()) / (point.getX() - center.getX()));
            if (point.getY() > center.getY()) {
                if (point.getX() > center.getX()) {
                    // bottom right
                    return -absSlope;
                } else {
                    // bottom left
                    return absSlope;
            } else {
                if (point.getX() > center.getX()) {
                    // top right
                    return absSlope;
                } else {
                    // top left
                    return -absSlope;
         * The main() method is ignored in correctly deployed JavaFX application.
         * main() serves only as fallback in case the application can not be
         * launched through deployment artifacts, e.g., in IDEs with limited FX
         * support. NetBeans ignores main().
         * @param args the command line arguments
        public static void main(String[] args) {
            launch(args);
       private class SteeringWheelGroup extends Group {
            public SteeringWheelGroup(int destinationWidth) {
                int topPadding = 0;
                Rectangle rect = new Rectangle(getImageWidth(), getImageWidth(), Color.RED);
                double scale = destinationWidth / rect.getWidth();
                rect.setScaleX(scale);
                rect.setScaleY(scale);
                Circle circle = new Circle(getImageWidth()/2, getImageWidth()/2, getImageWidth()/2, Color.BLUE);
                circle.setScaleX(scale);
                circle.setScaleY(scale);
                Group rotationGroup = new Group(/*rect,*/ circle);
                rotationGroup.setManaged(false);
                int width = getImageWidth();
                Rectangle clipRectangle = new Rectangle(0, 0, width, width / 2);
                Circle clipCircle = new Circle(width / 2, width / 2, width / 2);
                Shape clip = Shape.intersect(clipRectangle, clipCircle);
                rotationGroup.setClip(clip);
                this.getChildren().add(rotationGroup);
                //double h = calculateHeigthOverHorizon(angle, destinationWidth/2);
                //setTranslateY(-h+topPadding);
            public final int getImageWidth() {
                return 479;
    Here is how you can reproduce my effect:
    Grab the black handle
    Drag the mouse top and right until you approach the angle -90 (have an eye out on the console log)
    Let the mouse go: the handle will snap to 90 degree
    Grab the handle a second time and move further right
    You will see that the angle printed out do not match what you expect.
    Let the mouse go, the Handle snaps back to it's original position
    As the rotation does not happen around the polygon's center, I have to use a Rotaion effect, which is applied. While I can drag the shape from the rotated location the dragging is always measured from its base position.
    So what can I do to work around this?
    final Rotate rotationTransform = new Rotate(currentRotation.doubleValue(), centerPoint.getX(), centerPoint.getY());
    polygon.getTransforms().add(rotationTransform);
    If worse comes to worst, I can use a circular handle covering everything, then I can rotate around its center, but I would like to avoid this.

  • Simulating mouse drag events?

    Hi all,
    I am wrinting unit tests for my swing application. For one test I want to simulate a drag event over a panel. I have tried JFCUnit, but does not seem to work for this, so I am trying to write my own.
    I create 3 mouse events and post them on the system event queue. A mouse press event, a mouse drag event and a mouse release event. MouseEvent's do let you specify a drag start and a drag end point in their constructor. So I have tried using both, but neither works.
    Am I doing anything wrong? The component I'm operating on gets the mouse pressed and mouse released events, but thats all.
    any help much appreciated,
    Justin

    I tried using the Robot class alright, but it does really wierd things. I sometimes doesn't work for simulating dragging events. I have a component that you can drag anywhere on the screen using the mouse, without having to use the titlebar. I am trying to test this dragging, but with the robot class, it looks like it goes into an infinate recursion. The mouseDragged method gets executed thosands of times, and you can see the panel shifting from its origional position to the new position and back again for a few seconds. Could be a bug in Robot class.

  • Mouse dragged event - problem(logic problem?)

    Hi! I have a window which is started by a frame. At the moment I have a Mouse Dragged event. The ideea is that I would like to drag the window to various parts of the screen but as it is the window flickers a lot and it keeps on jumping to various locations when dragging it. Is there a way to redraw and move the window only once the mouse button was released from the drag and not all the time?!
    Thank you.

    if i understood your question correct setVisible(false) when you grab it setVisivble(true) when you release it. If you want it to be still shown in the ori�ginal place while dragging make a second window that stays at the starting location and id removed after the first diappears.
    An even better solution would be to remember the location of the mouse in a pousepressed event and then wait for mousereleased. (and set a boolean true if the mouse pressed was inside the window).

  • Error "No status object is available for Unknown Object " in Shopping Cart

    Hi all,
    We are getting error "No status object is available for <Unknown Object>" while creating shopping carts of any type .
    Please suggest if any configuration setting needs to be done.
    Thanks and Regards,
    Navdeep Malik

    Dear Navdeep
    The error is likely caused by one or more entries in table BBP_DOCUMENT_TAB that are without objkey or guid.
    did you delete some entries from SRM transaction tables?
    Check table BBP_DOCUMENT_TAB entries to see any GUID which is not present in the system.
    You can verify this by checking whether there is an entry in CRMD_ORDERADM_H (header) table
    with GUID = <guid stored in bbp_document_tab>
    Regards
    Lauren

  • A way to access SVG event data for an object?

    Is there a way to access the SVG event data for an object through scripting?

    post this in the correct forum - you will get a better response (btw the correct forum is KVM)
    to answer your question - any extra functionality above the MIDP1.0 specification will be manufacturer specific (and as such hardware dependant)
    I only know 2 of the APIs extensivly (the Nokia and Siemens) neither of these offer access to the phonebook or the message folder (it would be a security risk) I don't think they provide the cell id either.
    and no, there is no way to access the cellular phones OS. (on any phone!) it would completely destroy the purpose for having java on the phone.

  • Consuming extra mouse drag events?

    Hi,
    In my mouse drag listener, there is a bit heavy processing that can take slightly long time (doing some real time computation). If I move the mouse fast, then there would be a long pause before processing catch up.
    So my question is that if it is possible to remove some mouse drag events in the queue s.t. my computation only takes on the latest drag event.
    I tried java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue().peekEvent(), but it always returns null.
    Anyone could give a hint? Thanks a lot.

    This heavy processing should be done in a new thread and not the event thread. If the event thread is busy processing, it's not going to be able to respond to drag events. Once you do that, it would be easy to set a flag in that thread to notify it to stop processing and start with new values.

  • Default implementation of mouse drag event?

    Is there any Default implementation of mouse drag event?
    Say if the developer does not override and implement mouse drag event, still when the frame is dragged, the frame gets repainted itself in the new position. It indicates some default implementation of mouse drag event, but am unable to find out where it has been implemented.
    Why bother when everything works fine? I have a requirement to move my non-modal dialog when the frame is being dragged to another location. I tried adding mousemotionlistener to the frame, to the panel inside a frame, but the event does not reach my custom implementation of mousedrag event.
    Any clues?

    Moving the frame is a different listener: ComponentListener; add one to the frame. The frame's window decorations are OS territory, so I'm not sure if there's system dependence. I seem to vaguely remember some systems sending an event only after done moving, while others send the event as the frame moves.

  • JTable custom selection and mouse drag events

    Hello
    I am currently experiencing a problem when using a JTable and a custom selection. I have made a small example to demonstrate the probem. Selection works for this example by listening for when the user clicks or clicks and drags (button held down) and moves the mouse across cells in the table. For each MouseEvent received in the MouseMotionListener mouseDragged method I store the coordinates of that cell at the point of the mouse and render the cell at those coordinates with a line border allowing a more versatile cell selection. The problem that occurs is when you click+drag and move the mouse fast, it looks MouseEvents are created every x milliseconds so when you move fast there isn't a MouseEvent raised for each cell in the click+drag from A -> B. If you run the following example then click and hold down the mouse button and move fast downwards from the top of the table to the bottom you can see that not all the cells are selected vertically.
    Is there someway of increasing the mouse poll (if this is indeed the problem) during the click+drag or a better solution to this problem that any one knows!?
    I have tried attaching the example but it exceeded the message length for the forum post here is a link to code
    [http://www.oneandonlyluppy.pwp.blueyonder.co.uk/TableTest.java]
    [http://www.oneandonlyluppy.pwp.blueyonder.co.uk/TableTest.zip] <-- Contains the source and compiled classes
    I'll try adding the code again as a separate post
    Thanks
    Edited by: oneandonlyluppy on Jan 8, 2009 2:44 AM
    Edited by: oneandonlyluppy on Jan 8, 2009 2:45 AM

    AFAIK the mouse polling rate is OS dependent (being interrupt driven), and may even be affected by processor load. What you could do is store the mouse location (Point) of the last mouseDragged event, and compute a line to the current location, then use some coordinate geometry to identify any intervening cells which are presently being skipped.
    db

  • Mouse dragging events in NSWindow and NSView

    Hi, I have built and application that uses a single window that contains multiple components within it. The main component of the window is a custom NSView subclass that contains a number of CALayers. I want to be able to move these layers around the NSView subclass based on the mouseDown, mouseDragged, and mouseUp events entered by the user. I can detect and process mouse events fine within the NSView subclass, however, whenever I drag the mouse within the NSView subclass right after a mouseDown event, the WHOLE WINDOW will move. I do not want that to happen, that is, when I am dragging the mouse within my NSView subclass, I do not want the whole window to move. I want my CALayers, within the NSView, to move according to the mouse events that I am correctly tracking in the NSView subclass. I will very much appreciate any suggestions. Thank you very much in advance.

    Thank you very much for your response. Your tip is very useful. What I did before was change the window type in Interface Builder: replace the textured window with a regular window. This solved the problem, however, I could not find the property that needed to be adusted to control the window behavior. I learned something useful with your tip. Thanks again.

  • Mouse drag  event

    I'm trying to get the end position for a drag mouse event, but this will only gives me the starting position. And if I try to use Mousereleased() this doesn't get call during a drag. What I'm trying to do is if the user drags an item outside a dialog window, then I remove it from a list. Any suggestions?

    Hi !
    You have to overwrite the methods processMouseEvent(MouseEvent e) ans processMouseMotionEvent(MouseEvent e) from the JComponent.
    Example:
    public class YourClass{
      private Point clickedPoint;
      protected void processMouseEvent(MouseEvent e){
       if(e.getId() == MouseEvent.MOUSE_PRESSED){
        clickedPoint = e.getPoint();
       }else if(e.getID() == MouseEvent.MOUSE_RELEASED){
        clickedPoint = null;
       super.processMouseEvent(e);
      protected void processMouseMotionEvent(MouseEvent e){
        if(e.getId() == MouseEvent.MOUSE_DRAGGED){
          //do something
        super.processMouseMotionEvent(e);
    }

  • Events available in Generic Object Services (GOS)?

    Hello everybody
    Searched around in SDN and also tried to find something useful in our system (SWO1) but can't find useful information on GOS events so I guess it probably doesn't exist?
    I'm searching a way to catch GOS events when someone adds, changes or deletes an attachment (URL) in the generic object services of an object, e.g. for a material master (BUS1001006). I'd like to create a change document for this and based on that to trigger some further processing for one of our interfaces.
    Anybody out there knowing how to achieve this?
    TIA and best regards,
    Renaud

    There's a couple of BaDIs with GOS names such as GOS_SRV_REQUEST that might help.  Otherwise I'd try using SE30 with lots of logging options set on to trace where you may be able to grab this info from.  GOS subscriptions may be another thing to look at.
    Jonathan

  • How to get  the mouse drag event ?

    I Have a JTextField and I want to move a selected text in the JTextField from a location to another by pressing the mouse on selected text and dragging it to newer
    location in the same text field (Same as Microsoft word does).Will u help me out please .

    But i can't get it working for the same component i.e dragging a text from the JTextField and dropping it in the same text field
    will u please help me with the sample code for 1 JTextField.I will really be very thankful to u
    Please

  • Are there event handlers for graphic objects drawn with the CWIMAQViewer toolbar?

    Hi,
    I use the CWIMAQViewer in my VB.Net  application to display images from a CCD camera.  I want to use the toolbar that comes with the viewer to draw graphics (e.g. a circler) over the image.  Is it possible to get the position and radius  of the circle as I drag it and change its size?  If not, what library should I use (I do have the NI Vision module) to achieve my goal?  Thank you so much for your help.

    Try creating the circle as a ROI.  Then take a look at ROI properties.  As an example, ROITop Property: CWIMAQ.ROITop
    Jeff B.
    Applications Engineer
    National Instruments

  • Check mouse drag event in ListBox

    Hi,
           I want to check whether the mouse is dragged or not in List box without setting the property dragEnabled.
    Regards,
    Jayagopal.

    may be you can do this mouseDown -> listen mouseMove-> on mouseUp -> remove mousemove

Maybe you are looking for