 |
 |
tableView rectOfRow coordinate conversion
|
 |
|
 |
|
Mac Enthusiast
Join Date: Oct 2001
Status:
Offline
|
|
Im trying to add an NSShowAnimationEffect when a row is deleted from myTableView and ive almost got it, but im having trouble converting between screen coordinates and myTableView's coordinates. Im pretty sure that the coordinate system used by NSShowAnimationEffect is screen centric, while the point im getting from [myTableView rectOfRow:[myTableView selectedRow]] is view centric. Heres my code.
Code:
NSRect aRect = [myTableView rectOfRow:[myTableView selectedRow]];
NSPoint thePoint = NSMakePoint(NSMidX(aRect), NSMidY(aRect));
thePoint = [[myTableView window] convertBaseToScreen:thePoint];
NSShowAnimationEffect (NSAnimationEffectDisappearingItemDefault, thePoint, NSZeroSize, nil, nil, nil);
my (obviously flawed) methodology is to get a rect of the selected row, create an NSPoint at the center of this rect, convert this point to screen flavor and then pass it to NSShowAnimationEffect. sounds logical but unfortunately, i suck. Anyone feel like throwing me a bone?
(Last edited by 3R1C; Sep 15, 2004 at 08:55 PM.
)
|
3R1C
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Dec 2000
Location: sj ca
Status:
Offline
|
|
[myTableView rectOfRow:[myTableView selectedRow]] is actually in view coordinates, not window coordinates. You need to first convert to the window coordinate system before moving to screen. You can do this by:
Code:
thePoint = [myTableView convertPoint:thePoint toView:nil];
where the "toView:nil" means use the window as the "toView".
Disclaimer: I didn't actually try this.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Oct 2001
Status:
Offline
|
|
That totally worked. I actually had tried:
Code:
thePoint = [myTableView convertPoint:thePoint fromView:nil];
as well as:
Code:
thePoint = [[myTableView window] convertBaseToScreen:thePoint];
BUT I had never tried both at the same time. Thank you very much!
Code:
NSRect aRect = [myTableView rectOfRow:[myTableView selectedRow]];
NSPoint thePoint = [[myTableView window] convertBaseToScreen:[myTableView convertPoint:NSMakePoint(NSMidX(aRect), NSMidY(aRect)) fromView:nil]];
NSShowAnimationEffect (NSAnimationEffectDisappearingItemDefault, thePoint, NSZeroSize, nil, nil, nil);
(Last edited by 3R1C; Sep 15, 2004 at 08:54 PM.
)
|
3R1C
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |