[vtkusers] VTK Cocoa mouse problem
Drew McCormack
cormack at chem.vu.nl
Mon Feb 10 04:33:44 EST 2003
On Sunday, February 9, 2003, at 07:20 am, Chris Scharver wrote:
> Hello,
>
> I just noticed that mouse events aren't occurring in the correct place
> on Cocoa windows. The easiest way to see this is to move a
> vtkRenderWindow to the right side of the screen. Clicking the mouse on
> the left side of the window generates a mouse event with a value
> which makes the interactor spin to the right. The behavior is
> obviously incorrect.
>
> Adding some output to the source code, I found that the initial mouse
> down is properly read in the relative position in the window. However,
> beyond that (the internal do..while loop within [vtlCocoaGLView
> mouseDown]) the positions are read in absolute screen coordinates.
> This conversion should be handled by calling convertPoint:fromView:,
> which the code does. The window id of the event is 0, so somehow the
> screen is sending the event rather than the vtkCocoaGLView.
>
> I've copied the code into a stand-alone sample and it works fine, so
> there's something screwy somewhere in the VTK code. I've tried to copy
> application initialization and basic capabilities into a nib-less
> example, and everything runs fine there. I'm not sure what could be
> causing the problem since the same mouseDown code copied into another
> snippet runs fine. Any vtkCocoa developers know what may be happening?
>
> I've been trying to track through the code to create a fix, but I
> haven't had any luck. It's easy to see what's happening, but not why.
>
> Chris
Hello Chris,
I came across the same problem several months ago, but haven't had a
shot at tracking it down. I just implemented a hack, by creating a
category, copying the mouse event code, and adding the following line
to each mouse-event method:
NSPoint mouseLoc = [self convertPoint:[[self window]
convertScreenToBase:[theEvent locationInWindow]] fromView:nil];
I think you probably have done the same, right? Just like you, I do not
understand why this would be necessary. As you say, events are being
interpreted relative to the screen instead of the view. Why, I don't
know.
If you find the problem, I would love to hear it.
Regards,
Drew
======================================
Dr. Drew McCormack (Kmr. R153)
Afd. Theoretische Chemie
Faculteit Exacte Wetenschappen
Vrije Universiteit Amsterdam
De Boelelaan 1083
1081 HV Amsterdam
The Netherlands
Email cormack at chem.vu.nl
Telephone +31 20 44 47623
Mobile +31 6 483 21307
Fax +31 20 44 47629
More information about the vtkusers
mailing list