🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.programmer
4 messages
4 total messages Started by Bob Beauchemin Wed, 29 Jul 1992 16:24
Non-copyable TextField
#315
Author: Bob Beauchemin
Date: Wed, 29 Jul 1992 16:24
20 lines
1174 bytes
  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
Re: Non-copyable TextField
#366
Author: Drew Davidson
Date: Thu, 30 Jul 1992 14:52
55 lines
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      |
+--------------------------------+-------------------------------------------+
Re: Non-copyable TextField
#354
Author: & Garrett
Date: Thu, 30 Jul 1992 14:57
29 lines
1483 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?

Why not just set a regular TextField to be non-selectable?  Cut/copy/paste  
have to have a selection to work on.


Colin Garrett
colin@delphi.bsd.uchicago.edu
Re: Non-copyable TextField
#371
Author: Hans Peter Geiser
Date: Fri, 31 Jul 1992 07:38
11 lines
759 bytes
> 
>   I'm trying to make a subclass of TextField object that cannot be copied
> with the cut/copy keys or cut/copy menu entries. 

The easiest way to prevent a text of being copied is to send it the message  
[myText setSelectable:NO]. I'm not sure if you have also to sent the  
setEditable:NO message to the text as in IB you cannot make an editable text  
non-selectable.

Hans - Peter Geiser
hans@nextpoint.de
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads