Article View: comp.sys.next.programmer
Article #366Re: Non-copyable TextField
From: Drew Davidson
Date: Thu, 30 Jul 1992 14:52
Date: Thu, 30 Jul 1992 14:52
55 lines
2765 bytes
2765 bytes
In article <1992Jul29.162437.3218@agora.uucp> bobb@agora.rain.com (Bob
Beauchemin) writes:
>
> I'm trying to make a subclass of TextField object that cannot be copied
> with the cut/copy keys or cut/copy menu entries. I made a subclass called
> XTextField and set it up with a "empty" copy method (ie a copy method that
> does nothing but printf("copy method invoked").
> However, I can still copy the text and my custom copy method does not
> ever appear to get invoked during the COPY operation.
>
> I've read that all TextField objects share the same Text object for
> rendering text. Can I override the COPY method in this Text object somehow?
> Is this why my subclass of TextField with a custom COPY method will not
> work?
>
> Does anyone have/know of any examples of a TextField (or Text) subclass
> that cannot be copied?
>
> Thanks,
>
> Bob Beauchemin
> bobb@agora.rain.com
You are correct about the Text object. The TextField object doesn't have
firstResponder when you are typing text into the field, the Text object does.
One way to accomplish what you want is to subclass text that overrides the
copy:, cut:, and paste: messages then use this subclass in your window by
returning it via the Window's delegate message,
windowWillReturnFieldEditor:toObject:
here's some example code (implemented in the window's delegate):
- windowWillReturnFieldEditor:sender toObject:client
{ NXRect fRect;
static id ourFieldEditor = nil;
if (!ourFieldEditor)
{ fRect.origin.x=fRect.origin.y = 0.0;
fRect.size.width = fRect.size.height = 100.0;
ourFieldEditor = [[MyTextSubclass alloc] initFrame:&fRect];
}
return(ourFieldEditor);
}
Naturally you might want to have a flag in your subclass that has a flag that
can be set so not all the fields in your window behave this way.
- Drew
--
+--------------------------------+-------------------------------------------+
| Drew Davidson | The perfect development team: |
| Software Guy | One person paid per line of code written |
| First National Bank of Chicago | and another paid per line of code removed |
| drew@fnbc.com (NeXTmail) | - Frank Mitchell |
+--------------------------------+-------------------------------------------+
Technical Details
Message-ID:
<1992Jul30.145202.6302@fnbc.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!psinntp!juliet!newsReferences:
<1992Jul29.162437.3218@agora.uucp>Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.next.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!psinntp!juliet!news From: drew@fnbc.com (Drew Davidson) Subject: Re: Non-copyable TextField Message-ID: <1992Jul30.145202.6302@fnbc.com> Sender: news@fnbc.com Reply-To: drew@fnbc.com Organization: First National Bank Of Chicago, Chicago IL, USA References: <1992Jul29.162437.3218@agora.uucp> Date: Thu, 30 Jul 92 14:52:02 GMT Lines: 55