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 > NSBrowser: an enigma wrapped in a riddle

NSBrowser: an enigma wrapped in a riddle
Thread Tools
Mac Elite
Join Date: Sep 2000
Location: Norfolk, Va
Status: Offline
Reply With Quote
Jan 23, 2003, 01:39 PM
 
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
     
Gametes  (op)
Mac Elite
Join Date: Sep 2000
Location: Norfolk, Va
Status: Offline
Reply With Quote
Jan 27, 2003, 02:07 PM
 
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
     
Gametes  (op)
Mac Elite
Join Date: Sep 2000
Location: Norfolk, Va
Status: Offline
Reply With Quote
Jan 27, 2003, 10:41 PM
 
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
     
   
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 02:05 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