Jump to content

Rectangles not responding to mouse

- - - - -

  • Please log in to reply
No replies to this topic

#1
nain33

nain33

    Newbie

  • Members
  • Pip
  • 4 posts
Ok so we're creating a program that lets us draw certain shapes and move them around and stuff like that. I'm having a problem where certain rectangles don't respond to the mouse when i try to move or delete it. This only happens for some rectangles, others work perfectly :confused: I was wondering if anyone could help me out

Here are my codes for the relevant methods:

    /** Returns true if the point (u, v) is on top of the shape */

    public boolean on(double u, double v) {

        if((u < wd && u > x) && (v < ht && v > y)){

            return true;

        }

        else{

            return false;

        }

    }

    /** Changes the position of the shape by dx and dy.

    If it was positioned at (x, y), it will now be at (x+dx, y+dy)*/

    public void moveBy(double dx, double dy) {

        x += dx;

        y += dy;

        wd += dx;

        ht += dy;

    }

    /** Moves the current shape (if there is one)

    to where the mouse was released.

    Ie, change its position by (toX-fromX) and (toY-fromY)

     */

    public void moveShape(double changeX, double changeY){

        UI.println("Hello bitches"); //Ignore this :lol:

        Trace.printf("Moving shape by (%.2f, %.2f)\n", changeX, changeY);  //for debugging

        shapes[currentShapeIndex].moveBy(changeX-pressedX, changeY-pressedY);

        currentShapeIndex = -1;

        this.drawDrawing();

    }

If you wanna see any other methods, just ask.

Thanks




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users