home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.next.programmer
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!wupost!micro-heart-of-gold.mit.edu!uw-beaver!uw-coco!nwnexus!sounds!brianw
- From: BrianW@SoundS.WA.com (Brian Willoughby)
- Subject: Re: Transorming leaf to nonleaf & expand with one mouse click in NXBrowser
- Message-ID: <BxsB4o.11w@sounds.wa.com>
- Sender: brianw@sounds.wa.com (Brian Willoughby)
- Reply-To: BrianW@SoundS.WA.com
- Organization: SoundSoftware, Bellevue, WA, USA
- References: <83455@ut-emx.uucp>
- Date: Mon, 16 Nov 1992 01:07:36 GMT
- Lines: 64
-
- John Dawson writes
- | [...]
- | But what I want to do in my app is control click on nodes which can be
- | LEAF nodes, and expand them. See, each node in my tree has an array
- | associated with it, and I want to display the contents of the array
- | underneath the node in the browser. If I control-click on the node, I
- | can have my browser:fillMatrix:inColumn: method change the node from
- | leaf to nonleaf, if necessary, but it's too late then; the NXBrowser
- | has already gotten the click and interpreted it as a click on a leaf
- | node. I can't expand the node in the browser until the next mouse
- | click.
- |
- | What I'd like would be a method like "performClickOnSelectedCell" that
- | I could send to the NXBrowser, or better yet, "expandSelectedCell".
- | Nothing resembling these facilities seem to be present. Anybody have
- | ideas on how to fake it?
-
- I use -addColumn to accomplish this in my program. See the NXBrowser Class
- Description, paragraph two.
-
- In my case, the program supports editor/inspectors of multiple items at
- different levels in the browser simultaneously. In the case where editing the
- cell changes it from a leaf to a parent node, my -updateBrowser routine checks
- to see if this node is in the last displayed column, and if this is true a new
- column is added (which is automatically filled by NXBrowser when it calls its
- delegate). Here is the relevant excerpt:
-
- - updateBrowser
- {
- int i,
- selected = [theBrowser selectedColumn],
- last = [theBrowser lastColumn];
- id cell;
-
- [windowMusic disableFlushWindow];
- // reload all columns since the location of the edited cell is unknown
- for (i = 0; i <= last; i++)
- [theBrowser reloadColumn:i];
- // add a column if the selectedCell has become a branch
- if (cell = [[theBrowser matrixInColumn:selected] selectedCell])
- if (![cell isLeaf] && selected == last)
- [theBrowser addColumn];
- [[windowMusic reenableFlushWindow] flushWindowIfNeeded];
- return self;
- }
-
- Enjoy - I hope this helps...
-
- P.S. I just noticed that the 3.0 docs have changed the wording a bit for
- -addColumn. In 2.1, the wording implied to me that your code did not "need" to
- call this method because it was done for you. In 3.0, the wording has been
- changed to "your code should never invoke this method". Sounds somewhat
- alarming to me, but I can say that my code has worked fine running under 3.0,
- both as a 2.1 binary and recompiled as a 3.0 binary. My hunch is that the key
- is how I specifically -reloadColumn: the column which contains the node which
- has just lost its leaf status before trying to -addColumn, avoiding possible
- inconsistancies with any cached information in the NXBrowser instance.
- However, I haven't proven this hunch by testing the converse, since I just
- noticed the change in wording while investigating my response to this post (so
- thanks for the incite to insight).
- --
- Brian Willoughby Software Design Engineer, BSEE NCSU
- BrianW@SoundS.WA.com Sound Consulting and Signal Processing Software
- NeXTmail welcome - NO EMAIL SOLICITATION without prior permission
-