 |
 |
Attaching Windows to Rows in TableView
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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
|
|
Thanks Chuckit! I got working great now!
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
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
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|