Enable text box when checkbox is ON using objective c - objective-c

How do I enable a text box when I check the checkbox through bindings in Cocoa?

Bind the checkbox's value and the text field's enabled to the same property of the same object—usually either your File's Owner (typically a window controller, view controller, or document) or some kind of object controller (such as an array controller).

First you connect your text box to an IBOutlet.
And instead of using binding, you can set your button to fire an action method when it is touched (this is called an IBAction and there's a bit more detail in this related question)
When the state of the button (or in your case, checkbox) changes, the IBAction method gets called and based on the state of the checkbox, you can enable or disable your textbox via the outlet you connected.

Related

How to disable context menus with right mouse click in an NSTextField (Cocoa)?

I'm working on a Cocoa application that has editable text fields. These text fields need to accept values but don't need to be spell checked or use any of the other options given in the default context menu. I've read that the easiest way to remove the right click/ opt + click context menu is to override the function:
rightMouseDown:(NSEvent *)
I've done this in a custom NSTextfield class. This fix blocks the user from right clicking when the text box is enabled and unselected, but as soon as the user double clicks/enters the text field for editing the default right click functionality returns.
Is this because the firstResponder switches to a class in the inheritance chain upon trying to edit the field? Is this approach the right way to disable all context menu functionality for this NSTextField?
Thanks!
When a text field is editing, the actual first responder is the "field editor", an NSTextView supplied by the window. The field editor always uses the control on whose behalf it is acting as its delegate.
So, in order to influence its behavior with respect to the contextual menu, you need to use a custom subclass of NSTextField. (I guess you already are to override -rightMouseDown:.) Then, implement the text view delegate method -textView:menu:forEvent:atIndex: and return nil (i.e. no menu).

NSColorWell not sending action on click?

Inside my .xib, I've placed an NSColorWell inside an NSView, and connected an IBAction in the controller to the NSColorWell's Sent Actions (via File's Owner). I figured I would respond to a click in my controller and send activate to bring up the NSColorPanel.
But unlike other my controls, I'm not getting the IBAction called. Clicking invokes a drag action on the color. I noticed this control doesn't derive from NSActionCell (like all my other controls). What's the proper control that is supposed to be used to both display a color and invoke the NSColorWell when clicked?
(note: this is Xcode/IB 3.2.x)
You listed both osx and ios in the tags, but I'm guessing this is an OS X problem.
There is a "Bordered" checkbox in IB's Attributes Inspector for NSColorWell. This toggles between a button-style color well, which is what you're asking for, and a color well which you can only drag a color swatch from. Make sure that's checked and you'll get the action like you're expecting.

change button type programmatically

Is it possible to change programmatically the type of button in Xcode?
I am trying to change the type from "Info Light" to "Info Dark".
No, you can't. These button types are subclasses of UIButton, not settable properties. You can specify a type when creating a button in Interface Builder or when creating the button with the class method [UIButton buttonWithType:(UIButtonType)buttonType].
If you want to change the button type, I would suggest creating a button of each type with the same frame, one with the hiddenproperty set to TRUE. Toggle between them as needed by setting the hidden property. They can share the same target and action.
The question is a near-duplicate of this one:
Change UIButton type programatically

Get the representedObject values of NSCollectionViewItem NSButton click

I have read some questions and I find some very confusing and I don't really know if they answer my question.
I have an NSCollectionView implemented and connected to a Core Data context, everything shows correctly.
Now what I have is buttons in the view prototype, and when I click this buttons I need to get the value of the representedObject of that cloned view.
I have read and read and some parts are confusing to me, so I'm looking for a simple explanation.
Thank you for your time.
An action method takes one argument:
- (IBAction) collectionViewButtonClicked:(id)sender {
}
That sender is the control or other UI element (e.g., menu item) that sent the message.
With that argument, when your action method gets called, you know which button was clicked.
A button is a kind of control, and every control is backed by at least one cell. Cells have represented objects, too.
So, first, set the represented object of your button's cell to the collection view item that owns the button. (You can do this in the nib editor.) Then, in your action method, get the button's cell, then the cell's represented object (which is the item), then the item's represented object.
If the representedObject outlet doesn't show up in the nib editor, you probably have the button selected, not its cell. I recommend opening the nib editor's outline view using the button in the lower-left and then never, ever closing it.

How to set animation in silverlight listbox Item?

I have one observable collection with user control. And I am bind it in listbox. I want to set animation on listbox item. Like when mouse over on user control that time start some storyboard and when mouse leave from listbox item that time set storyboard to stop.
How can i do this?
Any idea?
You could start by defining your mouse over and mouse leave storyboards on your user control and passing your storyboards to your usercontrol view model in the manner described here:
how to call an animation in mainpage.xaml from login.xaml in silverlight 4
You could then assign mouse over and mouse leave events to your user control. Inside the events you'd cast the sender's DataContext to the type of your user control view model and then call the appropriate storyboard Begin method off of that view model instance.