Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > tableView rectOfRow coordinate conversion

tableView rectOfRow coordinate conversion
Thread Tools
Mac Enthusiast
Join Date: Oct 2001
Status: Offline
Reply With Quote
Sep 14, 2004, 07:04 PM
 
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
     
qyn
Dedicated MacNNer
Join Date: Dec 2000
Location: sj ca
Status: Offline
Reply With Quote
Sep 14, 2004, 08:18 PM
 
[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.
     
3R1C  (op)
Mac Enthusiast
Join Date: Oct 2001
Status: Offline
Reply With Quote
Sep 14, 2004, 09:49 PM
 
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
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:14 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2