Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
421
30
I am responsible for a Cocoa app with a number of standard Panels. These use NSTextFields to accept text input from the user. In earlier versions of the app one could paste text from the clipboard into these text fields. Now you can't. You get the standard error sound when trying to paste text into them. Many of these are in .nib files that haven't been changed for a long time. This problem effects panels in both .nib and .xib files. The only change is building the app on XCode 4 and running it on 10.7. I ran earlier versions of the app and you can paste text from the clipboard into the NSTextFields. At some point this stopped happening. I looked at the NSTextFields and they are set to editable. I don't see any other Interface Builder setting that would fix this.

Can anyone tell me how to restore this functionality?
 

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
421
30
I spent more time looking at this today. I opened several projects that use NSTextFields. In all but one, the NSTextFields won't accept text from the clipboard. I put the projects side by side and looked at the settings in Interface Builder. The only difference between the one that accepts text from the Clipboard and the others is that the one that works was created with the target deployment as 10.5 and XCode 3.2. Changing the settings in the projects that don't work to the above doesn't fix the problem. Older versions of the Application that were built with XCode 3 and before work but versions built with XCode 4 don't. Does anyone else have this problem? Does anyone have any ideas about how to fit it?
 

chown33

Moderator
Staff member
Aug 9, 2009
10,740
8,416
A sea of green
Please identify the exact OS version (10.7.what?), Xcode version (4.what?), and Mac model you're using.


Make a test case.

Create a new project, using the Xcode that gives problems. Create it for the target that gives problems.

Add the text field and a button to the nib, in the way that causes problems. Write some simple code, and connect the controls to the code. Connect the Edit menu to the code.

Make sure everything other than clipboard works as expected. Test the clipboard and see if it works. If not, bundle up the entire project and post it.


Ideally, write down each step as you do it during the creation process, and include that with the project. This list of steps is so someone else could follow the steps and create an identical project. However, it's also so someone else can see if you've left anything out that should be there. Leaving a step out won't always be obvious simply by looking at the end resulting project, hence the need for listing every step.


You could also look at Apple's sample code projects, find one (or more) that uses text fields, and see if they have the problem. If so, tell us which ones, so we can independently confirm.
 
Last edited:

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
421
30
OS X 10.7.3 XCode 4.3.2

Create a Cocoa single window project. Drag an NSTextField into the window and run it. You can paste text from the paste board into it. This is how it's supposed to work. Changing the project settings to the ones in my project won't break it. You can't drag a connection from the Edit menu to the text fields that are malfunctioning because they are in panels. The Edit menu is in MainMenu.nib and the text fields are in different .nib and .xibs. The Project is a Cocoa multiple document App and creating a test app for this would be a hassle. The .nib for the panel I've been using to try to fix this and the object that controls it were created in 2007 and haven't been changed since then. It worked until I "upgraded" to 10.7 and XCode 4 this winter. 10.7 will run older versions of the App correctly so I think that the problem is that this is a bug caused by building the project with XCode 4. I already spent a long time trying to figure this out and I hate to waste my time trying to fix things that are being caused by problems with Apple's development environment - which I've done a lot since XCode 3. I filed a bug report.
 

Sydde

macrumors 68030
Aug 17, 2009
2,552
7,050
IOKWARDI
Then I would look at the troublesome files and convert any that are nib sources to xib sources (actually, for consistency, I personally would just convert them all).
 

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
421
30
Then I would look at the troublesome files and convert any that are nib sources to xib sources (actually, for consistency, I personally would just convert them all).

Uh, didn't I say that the problem is happening in both types of files? It would be a lot of work to convert many .nibs into .xibs. Is there some fast way to do this, other than copying everything in the .nibs and pasting it into new .xibs? Wouldn't I have control drag all of the links to/from the new files?
 

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
421
30
I tried your suggestion to be sure...

I opened and saved one of the broken .nibs as .xib. Interface builder does save the IBOutlets and IBActions. The NSTextFields still won't accept text from the pasteboard.
 

knightlie

macrumors 6502a
Feb 18, 2008
546
0
OS X 10.7.3 XCode 4.3.2

Create a Cocoa single window project. Drag an NSTextField into the window and run it. You can paste text from the paste board into it. This is how it's supposed to work. Changing the project settings to the ones in my project won't break it. You can't drag a connection from the Edit menu to the text fields that are malfunctioning because they are in panels. The Edit menu is in MainMenu.nib and the text fields are in different .nib and .xibs. The Project is a Cocoa multiple document App and creating a test app for this would be a hassle. The .nib for the panel I've been using to try to fix this and the object that controls it were created in 2007 and haven't been changed since then. It worked until I "upgraded" to 10.7 and XCode 4 this winter. 10.7 will run older versions of the App correctly so I think that the problem is that this is a bug caused by building the project with XCode 4. I already spent a long time trying to figure this out and I hate to waste my time trying to fix things that are being caused by problems with Apple's development environment - which I've done a lot since XCode 3. I filed a bug report.

Wild stab in the dark here, but why are you connecting edit menu items to NSTextFields? Shouldn't Cut, Copy, etc. send their actions to the First Responder in the [x|n]ib? Sorry if I'm misunderstanding.
 

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
421
30
Wild stab in the dark here, but why are you connecting edit menu items to NSTextFields? Shouldn't Cut, Copy, etc. send their actions to the First Responder in the [x|n]ib? Sorry if I'm misunderstanding.

You're misunderstanding. Another poster told me to connect the edit menu to the text fields. I was pointing out that this is impossible because they are in separate .nib/xibs. Yes, Cut, etc. should send their actions to the text fields. Since I built my project with XCode 4.3.2 they don't, or more likely the text fields aren't responding.
 

knightlie

macrumors 6502a
Feb 18, 2008
546
0
Yes, Cut, etc. should send their actions to the text fields.

Cut, etc, should send their actions to First Responder, not to specific text fields. That's the way the default MainMenu.xib is configured. How can you allow for pasting into different edit fields when the Paste menu option sends its action to a single field?
 

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
421
30
Cut, etc, should send their actions to First Responder, not to specific text fields. That's the way the default MainMenu.xib is configured. How can you allow for pasting into different edit fields when the Paste menu option sends its action to a single field?

No, paste doesn't send it's action to a specific NSTextField. It sends it down the responder chain until an object responds to it. The selected NSTextField in the panel should respond. Most of these panels have only one NSTextField which is selected when I initialize it. A selected editable NSTextField should respond to the paste action but in my App they don't. They quit responding after I switched to XCode 4 and I can't figure out why and fix it. The error sound I'm getting is because nothing is responding to the paste action.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.