home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / next / programm / 7240 < prev    next >
Encoding:
Text File  |  1992-11-15  |  3.5 KB  |  77 lines

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