Interface Builder won't allow drag/drop of text control to window - objective-c

Noob dumb question, no doubt -- but here it is:
Trying to tutorialize myself with the Apple "Currency Converter" tutorial for Cocoa ( http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjCTutorial/05View/05View.html)
Embarrassingly, I'm stuck very early on where the instructions ask me to drag-and-drop a text field onto the Currency Converter window. When attempting to do so, I release the mouse and the text field runs animatedly back to the library palette, refusing to "stick" on the client area of the Window.
Clearly the window is readonly or lacks some state or prerequisite to accept the text field, but what?

Are you sure you're dragging a view object and not a cell? Double check that you're dragging NSTextField and not NSTextCell.

Be sure you're not grabbing a text CELL.
When you select the text field from the Library, check that the description is NSTextField

Have you added a view to the window? Because if there is no view then you won't be able to add any controls.
Drag a "View" object over to your window.

Related

Objective C image click action

I have seen this in other programs and am trying to replicate it.
I have an image on one of my forms that someone can drag-and-drop an image into. I would like to allow the user to click on that image to pop up another dialog that they could instead select a "stock" image if they choose to.
I don't see an outlet I can use for the click and putting a transparent button over the top would defeat my ability to drag and drop an image on to it.
I realize I could just change the image to a button instead but I prefer to use an image if possible.
How can I make an image clickable?
This is OSX by the way, not IOS.
Quoting from another question:
By default, NSImageView doesn't react to -mouseDown:, or -mouseUp: like other NSControl subclasses (namely NSButton) do.
The solution is given in an answer elsewhere - subclass NSImageView and appropriately handle the click event (as linked).
Drag in the standard NSButton.
Uncheck the Bordered checkbox.
Clear the Title text.
Set the Image (and optionally, the alternate image).
Also, if you are using layout constraints to set button size to image view size, don't forget to set vertical hugging/compression resistance priorities to low values (say 1).

What Cocoa Views and Controls Will Create Something like Part of the Network Prefs Display (Mac OS)? [duplicate]

This question already has an answer here:
NSTableView with +/- buttons like in System Preferences using only Interface Builder
(1 answer)
Closed 7 years ago.
I'm building an OSX app and want to create a set of controls similar to what's found at bottom of the standard Network Preferences configuration panel. I'm running into some layout problems that I wouldn't have expected.
These are my specific questions:
What contains the 3 buttons so there's similar shading all they way across the row where the buttons are positioned? In particular, what's causing the area without buttons to have shading?
How do you do this without getting a double border where the row of buttons meets up with the table?
I want to do this with an xib file. This may be incredibly simple, but I'm missing something I guess.
I find that if you make a button with style "Gradient" and type "Momentary Change", then it looks like the other buttons but does not respond to clicks, so you can use that as the area after the last button. (The NSMomentaryChangeButton is documented as changing the image and title when clicked, so if you don't use an image or title, nothing should change.)
If you check Refuses First Responder in the attributes inspector, then it will not be possible to highlight this blank button using Full Keyboard Access.
Ken Thomases also brings up the issue of the blank button being shown as a button to Accessibility. One can fix that by using a subclass of NSButtonCell that has just one method:
- (BOOL)accessibilityIsIgnored
{
return YES;
}
I think that's easier than writing a custom view.
As d00dle says, avoid double borders by slightly overlapping things.
Since you want the slack space to have the same background as the buttons, and since the buttons can change appearance from release to release of the OS, the best thing to do is to get the frameworks to draw it like it would the buttons.
Rather than using an actual button as JWWalker suggests, I have used a custom view that leverages NSButtonCell to draw the background. The advantage is that you can be sure there's no chance of getting undesirable behavior. For example, a button could get focus (for users who have All Controls selected in System Preferences > Keyboard > Shortcuts > Full Keyboard Access) so that the user could Tab to it. Accessibility will report the presence of the button through VoiceOver. Etc.
Configure the button cell just like the buttons (set buttonType and bezelStyle). In the view's -drawRect: call [buttonCell drawWithFrame:rect inView:self];, where rect is similar to the frames of the buttons. Since one way to avoid double borders is to make the buttons larger than the view's bounds, you may need to do the same for rect. For example, you might want to use NSInsetRect(self.bounds, -1, -1).
The buttons are buttons... This can be accomplished with a custom view drawing border and the background "shading".
To avoid the double border where the table and the custom view meet you simply align it so they overlap by 1 point (pixel) or avoid drawing the top border in your custom view.
I don't know of any standard object capable of doing this.

How can I see properties of hidden label?

I am reworded the above question.
Let's say I am using 20 toolbox buttons and or labels or whatever on a VB window app form, and I have changed the default colors, size, and so on. Is there a way to view in code or design view all the properties and values that have been changed for any one tool (object) in a pop-up window.
In other words instead of having to go to properties and scroll, I push a hot key and magic! In one small pop-up window, I can see the changes for btnone, or lblTwo and or even better, make changes on the fly or go back to default values, or change to new values. Like an Xray format tool in brackets, or google.

child views of window doesnot resizes using autolayout feature

I have a textfield created using xib over my window.I have enabled autolayout property for my window.I want my textfield to grow horizontally to meet the window bounds.My window grows but not the textfield. Please help!I am using Mac OS Lion
Did you read my answer on your other question? Select the text field in Interface Builder. A blue line connecting the field to the right side of the window represents a constraint that will cause the right side of the field to stay a fixed distance from the edge of the window. If you drag the text field so that it clicks into place (the human interface guidelines defined distance away from the edge of the window), then that will create the constraint. If not, you can do it by hand from the menus: Editor > Pin > Trailing Space to Superview.
You might find the documentation helpful, since it has images and explanation and such. There's a bunch! Interface Builder, programming guide, sample code, release notes, WWDC video.

Creating a view for user to fill up a form

I'm creating a view which provides some fields for the user to fill in - address, phone number etc.
I've seen apps that have populated fields with grey text like 'Fill in your name here' on the Name field, and when the user taps on it the text is gone, a keyboard appears and the view is zoomed in to the textfield(or whatever it is). Also, after filling up that field tapping the 'Next' button on the keyboard brings the user to the next field. I'm trying to do the same but I have no idea where to get sources on this. Pardon my poor googling skills ;p
Tried UITextView and UITextField but there isn't anything related to this on the Interface Builder. Figured it lies with the codes?
It'd be great if I can get some explanation or some links on how this works (: Thanks!
EDIT: okay I played around with the Interface Builder a lil more and realized I could set placeholder as the grey text.
It is in fact a UITextField.
You can get the greyed out text by setting its placeholder property.
I am not sure what you mean by zooming but usually they do use a scroll view or adjust the frame so that it isn't blocked by the keyboard.
The Next button is made available using a UIToolbar instance as the text field's inputAccessoryView. However the implementation is one's own and is not framework provided. You can look at this example to get started.