IBAction in table cell view won't be fired - objective-c

I am making my first Mac OS X application and I'm stuck with a problem.
I created a NSTableView on my window linked to a NSArrayController and I'd like to call a method after stopping to edit a textfield cell. So I've selected to call an action when end editing, as you can see in the following screenshot:
After, I've created an IBAction for it:
It generated this code in my AppDelegate.h:
- (IBAction)stopEditingHeaderNameCell:(id)sender;
And then I edited the IBAction in AppDelegate.m in order to show a NSLog message when the cell is edited:
- (IBAction)stopEditingHeaderNameCell:(id)sender
{
NSLog(#"test");
}
However, when I stop editing the cell by pressing enter or clicking in another element, nothing happens. I already tried to apply this IBAction to a NSTextField and it works perfectly, but it doesn't call the IBAction when applied to this text field cell.
Can anyone help me to solve this?
Thanks!

This is not the way you do this with text field cells in a table view. You need to make your app delegate the delegate of the table (you can connect this in IB), and then implement controlTextDidEndEditing:. This method will be called when you end editing (by tabbing out of the cell or clicking on another row or column).

Related

Accessibility: didSelectRowAtIndexPath not called when cell selected with voiceover

I have a very simple UITableView with a custom class for my cells. The cells consist of various labels (isAccessibility=NO).
I have an accessibilityValue set for each cell, and isAccessibility=YES/enabled in Storyboard for each cell.
When the user double-taps to select the cell...nothing happens. didSelectRowAtIndexPath, which contains my navigation logic, does not get called. At other locations in my app that use segues work fine, with the same cell setup.
What am I doing wrong that would make didSelectRowAtIndexPath not get called?
Edit: this code works fine without Voiceover. Tapping the cell calls didSelectRowAtIndexPath as expected. Voiceover simply isn't triggering didSelectRowAtIndexPath.
I have got the same problem.
Fix below work for me
cell.isAccessibilityElement = YES;

focus on UITextField inside a UICollectionViewCell

I have created a custom UICollectionViewCell that contains a UITextField inside of it which is only accessible when the cell is selected. The CollectionView has multi select enabled and the problem is that when trying to select the UITextField to type in it, the cell is deselected instead of giving the TextField focus.
How do I allow focus on the UITextField inside of the CollectionViewCell without causing the cell to be deselected?
Note: I've also tried adding buttons to the cell template and the button actions are not getting called either. It seems as though the cell itself is capturing all of the touch events and not passing them along to child views.
I'm not sure what the original problem was, but I solved it by re-creating the UICollectionViewCell interface inside the UICollectionView in my storyboard instead of loading it from a different .xib file.

NSTextView - How to detect when it is clicked?

I'm trying to do this:
- (IBAction)textFieldSelected:(id)sender
{
printf("clicou no text\n");
}
I "connect" this to my NSTextField through the Interface Builder.
When I first start the app, the this NSTextField is already focused. Then I click on a second NSTextField, and my first one lose the focus and I get the print statement. Clicking back and forth between theses NSTextField I see that the print statement is just called when I click on the NSTextField that it is not attached to it. I believe that it just happens when the first one loses the focus.
Q1: How do I do to have this print statement when the use click on the NSTextField (when it gets the focus)?
Q2: How do I avoid it to get the focus automatically when the app starts?
Create the custom class of NSTextfield and then implement below method, so that whenever focus goes to the textfield below method will get called:-
-(Bool)becomeFirstResponder{
return YES}

UIPicker with UITextField

I made a research and all posts here are very blury regarding this issue.
I would like to use a UIPicker when pressing on a UITextField.
I would realy appriciate a step by step guide.
I tryd all posts here but every post gives me only a portion of what I need and I can't seem to connect it all together.
This is the last part of my application and i'm going crazy to finish it..
Thank you in advanced!
Gal
There is an inputAccessoryView property that contains a view that will appear instead of a keyboard on the bottom of the screen. Create a UIPicker, adjust its frame, provide values and assign it to the inputAccessoryView property.
UIPicker will appear when user taps on your UITextField.
If you don't need editing, you may use a UILabel instead of the UITextField. Solution is the same. I have a ready-made class if you need.
Here's a way:
http://www.youtube.com/watch?v=t_F1ex5opgA&t=14m10s
-(BOOL)textfieldShouldBeginEditing:(UITextField *)textField
where textField is the name of your text field.
Call your UIPickerView and return NO so that your picker is loaded rather than the keyboard.
The idea is to call an action that opens the UIPicker when the user taps the UITextField. Because the UITextField does not responde to the usual touchUpInside events that UIButtons respond to, I would just overlay a transparent UIButton on top of the UITextField and just in case, make the text field's userInteractionEnabled property NO. Hook the UIButton to responde to touchUpInside and call a method that opens the UIPicker. Another option would be an immediate response to the text field's touch by implementing "textFieldShouldBeginEditing" and immediately resigning the text field.
The next step would be to present the UIPicker - if we are talking about iPad, this would best be done by using a UIPopoverController. On iPhone, maybe consider bringing it up modally. When you create the view controller that holds this UIPicker, be sure to add a delegate property to it so that whatever value that was selected on the picker can be transfered back to the main view controller and on to the UITextField.
Hope this helps with getting you started.

How can I get a nstableview to send an action when the user double-clicks an editable cell

I am trying to emulate the behavior found in finder and itunes. Single click on a selected object edits it. Double click opens the object.
I have set the doubleAction of the tableView but like it says in the documentation. "If the double-clicked cell is editable, this message isn’t sent and the cell is edited instead." I dont want this. Is there a way i can get that message sent even if the cell is editable? I really have no idea how to begin implementing this. Any general pointers would be appreciated.
A quick thought comes to mind... turn off editing for all cells. This way a double-click will always call your method. Then in the method do your double-click thing but also decide if the cell should be editable (and if so start editing the cell).
Did you have set the Action-target?
In you ViewController you should have a:
[self.tableview setTarget:self];
[self.tableview setDoubleClickAction:#selector(mydoubleClick)];
-(void)mydoubleClick:(id)sender{
...
}