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 > Attaching Windows to Rows in TableView

Attaching Windows to Rows in TableView
Thread Tools
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status: Offline
Reply With Quote
Dec 12, 2002, 12:27 AM
 
Ok, I want to make it so that each time a cell in a certain column of a talbe column is edited, a little window with an NSTextView in it pops up just below the edited cell.

Here is what I have done so far. I have subclassed NSWindow to make a window borderless and without a top bar. I also have it so that when the right cell is edited my custom window appears, but it appears in the wrong spot. I am still learing about coordinates, so hopefully someone can tell me what is wrong with this code. This is what gets called, when the text begins editing:

- (void)textDidChange {

if([myTableView editedColumn]==6) {

NSRect aRect =[myTableView frameOfCellAtColumn:6 [myTableView selectedRow]];

aRect = [myTableView convertRect:aRect toView:notesView]; //notesView is my NSTextView in my custom window


NSPoint origin = NSMakePoint(aRect.origin.x, aRect.origin.y);
[notesWindow display]; //this is my custom window
[notesWindow setFrameOrigin:origin];


[myParentWindow addChildWindow:notesWindow ordered:NSWindowAbove];
[notesWindow makeFirstResponder:nil];
}
}

Can someone please lend a hand to a newbie trying to do things he doesn't know how to do?

:-)
(Last edited by macrophyllum; Dec 12, 2002 at 12:34 AM. )
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Dec 12, 2002, 06:38 PM
 
Well, first of all, I kind of wonder why you have the textview in another window. Why not put it in the same one?

But anyway, your problem is that -[NSWindow setFrameOrigin:] takes a point in screen coordinates. You're converting the point to notesView's coordinate system instead.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status: Offline
Reply With Quote
Dec 12, 2002, 07:23 PM
 
The reason I don't have the textview in the same window is because there is no place for it. My main document window is basically just a tableview and toolbar, but I would like to make it easier for the user to be able to enter in large strings in the one column (the "notes" column) in a more conevient manner, thus the "pop up" window. I want it so that when the user starts to edit the notes column, a small window with just the textview in it appears and they type into that instead.

So, do you know how to convert my frame coordinates to screen coordinates?
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Dec 12, 2002, 09:36 PM
 
Originally posted by macrophyllum:
So, do you know how to convert my frame coordinates to screen coordinates?
Here's a stab at what your code ought to look like:
Code:
- (void)textDidChange { if([myTableView editedColumn]==6) { NSRect aRect =[myTableView frameOfCellAtColumn:6 [myTableView selectedRow]]; NSPoint origin = aRect.origin; origin = [myTableView convertPoint:origin toView:nil]; origin = [[myTableView window] convertBaseToScreen:origin]; [notesWindow display]; //this is my custom window [notesWindow setFrameOrigin:origin]; [myParentWindow addChildWindow:notesWindow ordered:NSWindowAbove]; [notesWindow makeFirstResponder:nil]; } }
I don't know anything about child windows, since I don't have Jaguar. But hopefully nothing needed fixing down there.

EDIT: Damn smilies.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status: Offline
Reply With Quote
Dec 13, 2002, 10:41 AM
 
Thanks Chuckit! I got working great now!
     
   
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:57 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