Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > The most frustrating problem with Cocoa yet.

The most frustrating problem with Cocoa yet.
Thread Tools
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
May 12, 2001, 12:00 AM
 
Why the heck won't my textfield become editable I don't know what to do i have looked through all of the frameworks related to text for hours. I set my textfield as enabled and editable - why won't it let me edit it! What's going on?
This is a PLEA if anybody knows anything,anything at all about why a textfield may not want to even show a cross hair above it in this manner please tell me! I need to know.
I'm almost literally pulling my hair out!
Thank you so so much for any help from anybody.
David Kopec

------------------
Think Different.
     
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status: Offline
Reply With Quote
May 12, 2001, 02:04 AM
 

Usually I would say to make sure the outlet in the nib is set, and that the nib has been loaded when you're calling your code. If those aren't true, then the textfield variable is nil, and nothing will happen when you send messages to it. Break in that area in gdb to print out the variable, or just NSLog it to make sure.

However, if the correct cursor isn't showing up, and you can't select any text in there either...

Is it possible that a transparent view has been layered over top of the textfield in the nib? That might explain it if the textfield does not respond to any mouse clicks at all.

Just to make sure, this is a regular NSTextField right, not a subclass where you might have overridden something important?

If all else fails, you can try deleting the textfield and putting in another one (connecting the outlet again, etc.). Can't see how it would help but you never know.
     
davecom  (op)
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
May 12, 2001, 10:31 AM
 
This textfield was not created in interface builder, it is programatically allocated. The text can be selected, but it gets selected using the regular pointer(arrow). I've done the setEditable and setEnabled methods properly to YES. It is not a subclass of NSTextField.

Thank you for repsonding,
David
     
ali
Forum Regular
Join Date: Sep 2000
Status: Offline
Reply With Quote
May 12, 2001, 12:29 PM
 
Is there anything special about the window the text field is in? Is it also programmatically created, or is it extracted from a nib? If latter, and you have a regular IB created text field in the same window, does it fail the same way?

Ali
     
davecom  (op)
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
May 12, 2001, 11:01 PM
 
Yes, there is some special stuff about the window. It is of type NSBorderlessWindowMask. It is created programatically. It has no border and is built from a custom class, it also has special stuff in the mousedown and dragging methods to allow it to be dragged from any part of it. The two textfields, one in a drawer, and one in the actual window both have the same above described problem. For more information about what the windows are like download the old version of URL Box(1.1) from macupdate,stepwise,versiontracker, or download.com.

Thank you for your continued support,
David
     
Forum Regular
Join Date: Mar 2001
Status: Offline
Reply With Quote
May 13, 2001, 02:16 AM
 
Davecom, I have the solution

Your window is a subclass of NSWindow, and you have initialized the window with NSBorderlessWindowMask. In this case, your window cannot be the keyWindow, nor the mainWindow. It means that it does not respond to key Events. All buttons and sliders are grey, not blue, like a non selected window (because it cannot be the main window)
In your NSWindow subclass implementation, just add :
- (BOOL)canBecomeKeyWindow
{
return YES;
}

- (BOOL)canBecomeMainWindow
{
return YES;
}

(please, verify spelling of these functions in NSWindow documentation)
And it is magic ! You will be able to select, edit, ... :-)
You can find more info on these two overrides in NSWindow help documentation.
Imagine that my signature is here...
     
Forum Regular
Join Date: Mar 2001
Status: Offline
Reply With Quote
May 13, 2001, 02:18 AM
 
double post...

[This message has been edited by hELLO wORLD (edited 05-13-2001).]
Imagine that my signature is here...
     
ali
Forum Regular
Join Date: Sep 2000
Status: Offline
Reply With Quote
May 13, 2001, 02:34 AM
 
Borderless windows are not in general designed for use with UI elements... I believe hELLO wORLD has hit it right on the head and his suggestion should help. Let us know!

Ali
     
Forum Regular
Join Date: Mar 2001
Status: Offline
Reply With Quote
May 13, 2001, 03:16 AM
 
ali,

I know this works... I had the same problem...
I have spent time to read documentation about NSEvent, NSResponder, NSApplication, NSWindow, and to test different kind of stuff.
I had noticed that my window responded to key Events when it was normal, but not when it was NSBorderlessWindowMask... So I have found that keyWindow and mainWindow stuff, tried it and worked fine.
When a Window is initialized with NSBorderlessWindowMask, canBecomeKeyWindow and canBecomeMainWindow are automatically set to NO.

Cocoa is not finished yet, nor documentation. But is is very good yet, and very useable. The AppKit framework is very promising and is open to really great improvements! This is the easiest way to program major apps that needs to use intensively System Libraries or Frameworks.
Imagine that my signature is here...
     
davecom  (op)
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
May 13, 2001, 01:25 PM
 
A member of the MacNN community has saved the day once again. It works perfectly now. You've saved me countless hours. Email me at davecom@mac.com with your real name if you would like to be in the readme file of URL Box.

------------------
Think Different.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 10:04 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2