 |
 |
NSBrowser: an enigma wrapped in a riddle
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Norfolk, Va
Status:
Offline
|
|
I'm still new to all this, so the ignorance is all mine, but this element has been giving me the hardest time ever. After a few days of trial and error and research, I finally figured out how delegation works and how the message (void)browser:willDisplayCell:atRow:column actually translates into (NSCell)createCellForBrowser:atColumn:row:
via some unknown form of reasoning.
Sorry for the venting; I do actually have a question.
How do you display new columns when a cell is selected?
is it via the action method you attach to the browser in IB?
or is it via the delegate method (BOOL)browser:selectRow:inColumn:?
also, in the docs for that method it says the burden of cell selection is on the user...but how does that work? In an earlier phase of my project I had multiple columns up and running, just identical, without ever having implemented 'cell selection'.
(or am I just being dense and column creation is done in the original 2 delegate methods for NSBrowser?)
note: I am not working with path data; each column and element is generated via algorithm at run time.
Anyway, thanks. The tutorials are kinda sparse on this subject.
|
|
you are not your signature
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Norfolk, Va
Status:
Offline
|
|
How about this then: can anybody tell me the order of operations when you select a cell in a browser?
What I'd like to do is make a one-column browser, then when the user selects a cell it opens the selected file in the editor field. The problem is that the browser apparently sends its action method before it actually selects the cell. My program crashes because when I send the browser the selectedRow: method it returns nil.
How the heck do I perform the action after the cell has been selected by the user, and is there any easy way to get the cell's coordinates?
Speaking of, is there something I'm missing about how you're suppossed to use an NSBrowser? Because I can't even imagine why you would ever want the cell itself returned, and not its coordinates (to compare with a data structure) or at least it's title... but the cell itself?
Please, I've been working on this for 3 days now. I'm ready to be told the answer.
Thanks
|
|
you are not your signature
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Norfolk, Va
Status:
Offline
|
|
Ok, I may have had a breakthrough (for posterity, here it is):
Each NSCell can be given a title value with [cell setTitle:string] and an object value with [cell setRepresentedObject:object]
Then, after establishing each cell in the delegate method browser:willDisplayCell:atRow:column with these calls, the user selecting the cell will call the browser's action method.
From within this action method, use [[sender selectedCell] representedObject] to get whatever data you want to deal with from the cell, including creating the future column. There is no need for (what I tried initially) creating a backround data structure of NSArrays of NSArrays of NSDictionaries (to mimic columns, rows, and pairs of data).
The trick was moving backwards through all the documentation of inheritance, and alot of trial and error. Who knew that programming had so much in common with the scientific method?
|
|
you are not your signature
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

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