home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / next / programm / 5375 < prev    next >
Encoding:
Text File  |  1992-07-30  |  2.6 KB  |  68 lines

  1. Newsgroups: comp.sys.next.programmer
  2. Path: sparky!uunet!psinntp!juliet!news
  3. From: drew@fnbc.com (Drew Davidson)
  4. Subject: Re: Non-copyable TextField
  5. Message-ID: <1992Jul30.145202.6302@fnbc.com>
  6. Sender: news@fnbc.com
  7. Reply-To: drew@fnbc.com
  8. Organization: First National Bank Of Chicago, Chicago IL, USA
  9. References: <1992Jul29.162437.3218@agora.uucp>
  10. Date: Thu, 30 Jul 92 14:52:02 GMT
  11. Lines: 55
  12.  
  13. In article <1992Jul29.162437.3218@agora.uucp> bobb@agora.rain.com (Bob  
  14. Beauchemin) writes:
  15. >   I'm trying to make a subclass of TextField object that cannot be copied
  16. > with the cut/copy keys or cut/copy menu entries. I made a subclass called
  17. > XTextField and set it up with a "empty" copy method (ie a copy method that
  18. > does nothing but printf("copy method invoked").
  19. >   However, I can still copy the text and my custom copy method does not
  20. > ever appear to get invoked during the COPY operation.
  21. >   I've read that all TextField objects share the same Text object for
  22. > rendering text. Can I override the COPY method in this Text object somehow?
  23. > Is this why my subclass of TextField with a custom COPY method will not
  24. > work?
  25. >   Does anyone have/know of any examples of a TextField (or Text) subclass
  26. > that cannot be copied?
  27. >   Thanks,
  28. > Bob Beauchemin
  29. > bobb@agora.rain.com
  30.  
  31. You are correct about the Text object.  The TextField object doesn't have  
  32. firstResponder when you are typing text into the field, the Text object does.   
  33. One way to accomplish what you want is to subclass text that overrides the  
  34. copy:, cut:, and paste: messages then use this subclass in your window by  
  35. returning it via the Window's delegate message,  
  36. windowWillReturnFieldEditor:toObject:
  37.  
  38. here's some example code (implemented in the window's delegate):
  39.  
  40. - windowWillReturnFieldEditor:sender toObject:client
  41. {    NXRect        fRect;
  42.     static id    ourFieldEditor = nil;
  43.     
  44.     if (!ourFieldEditor)
  45.     {    fRect.origin.x=fRect.origin.y = 0.0;
  46.         fRect.size.width = fRect.size.height = 100.0;
  47.         ourFieldEditor = [[MyTextSubclass alloc] initFrame:&fRect];
  48.     }
  49.     return(ourFieldEditor);
  50. }
  51.  
  52. Naturally you might want to have a flag in your subclass that has a flag that  
  53. can be set so not all the fields in your window behave this way.
  54.  
  55. - Drew
  56. --
  57. +--------------------------------+-------------------------------------------+
  58. |        Drew  Davidson          | The perfect development team:             |
  59. |         Software Guy           | One person paid per line of code written  |
  60. | First National Bank of Chicago | and another paid per line of code removed |
  61. |     drew@fnbc.com  (NeXTmail)  |                     - Frank Mitchell      |
  62. +--------------------------------+-------------------------------------------+
  63.