Need to get the position of mouse pointer when release

291 Views Asked by At

I am using IKImageView for the functionalities of Image.

- (IBAction)switchToolMode: (id)sender
{
    // switch the tool mode...

    NSInteger newTool;

    if ([sender isKindOfClass: [NSSegmentedControl class]])
        newTool = [sender selectedSegment];
    else
        newTool = [sender tag];

    switch (newTool)
    {
        case 0:
            [_imageView setCurrentToolMode: IKToolModeMove];
            break;
        case 1:
            [_imageView setCurrentToolMode: IKToolModeSelect];
            break;
        case 2:
            [_imageView setCurrentToolMode: IKToolModeCrop];
            break;
        case 3:
            [_imageView setCurrentToolMode: IKToolModeRotate];
            break;
        case 4:
            [_imageView setCurrentToolMode: IKToolModeAnnotate];
            break;

    }
}

After the [_imageView setCurrentToolMode: IKToolModeAnnotate]; called i need to get the current mouse position (After drawing the shape). IKToolModeAnnotate is default function so i am not able to find where the control goes next.

Can anybody solve my problem.

1

There are 1 best solutions below

0
On

From NSApplicationyou always can get the last respectively current event by calling [NSApp currentEvent]. From that you can extract the mouse location.

Alternatively you get the location via [NSWindow mouseLocationOutsideOfEventStream]. I recommend to read up on NSEventso you know the differences between these locations, which is the coordinate system used for the point. See also NSEvent documentation .