UITextField: when "Done" is shown in the keyboard? - objective-c

I have working on implementing sign up screen, and there are three input fields and custom gender selection buttons below them. Now when first field becomes first responder then "Next" button is shown in the right bottom keyboard. Pressing "Next" moves to the second field, and the pressing it again moves to the third field and shows "Done".
I need to override and show "Next" instead "Done", so that a user could press it, I would close keyboard and scroll the screen a little bit so he would see he needs to select gender. Just trying to figure out what causes to show "Done" on last textField.

Try this one :
[textField setReturnKeyType:UIReturnKeyDone];

Related

Change focus on a Button in a Panel using the arrow keys

Assume you have a Form with ten Buttons on it, with the first one having the focus, so that it can be clicked by hitting the Enter key on the keyboard. Now, you can set the focus to the next button simply by pressing the Down arrow key. This works out of the box.
Then I constrain this functionality to the first three Buttons on the Form.
So, when the third Button on the Form has the focus and I press the Down arrow key, the first Button - instead of the forth button - should receive the focus.
Question:
how can I change the focus to another button outside the Panel with arrow key?

UIReturnKeyDone return or other feedback?

So I'm using textfield.returnKeyTYpe = UIReturnKeyDone in my code with my UIKeyboard. The problem that I am running into is that the done button and the hide keyboard button are both performing the same function in that, once they are clicked the keyboard hides but the program continues on to the next field and the keyboard pops up right away.
I want to know if there is something that the UIReturnKeyDone returns when clicked that I can grab to differentiate between clicking the Done key and the hide keyboard key.
Sorry if that does't make sense, I am new to all this.
It now make sense, You need to create UIButton and press it to hide keyboard.
When you want to hide keyboard.
[textView resignFirstResponder];

How do I properly move a scrollview when assigning a first responder?

I have a form in a UIView which consist of multiple textfields, couple of textviews and two fields that are interacted with by the means of an invisible button overlaid on them. When you click on a textfield, the keyboard pops up for text entry and I added a toolbar on it for navigating to the previous and next data entry (whatever the data entry is, be it a textfield, textview or one of the two special cases that are interacted with a button). Now, when I navigate with between textfields with those buttons everything works fine. My scrollview's content moves along the element that becomes the firstresponder (with the help of a piece of code from stackoverflow that scrolls the view while taking into account the height of the keyboard that hides a good portion of it). Here is a visual example.
The problem arises when I want to switch out of a specific data entry (date) that interacts with a hidden button. I'll give some context first. Those data entries show datepickers (one for the date, another for the time) in action sheets, and those action sheets also have navigating button in a toolbar, like so.
The code from stackoverflow that readjust the view do so in the didBeginEditing delegate methods of the textfields and textviews, so when I assign them first responder the scrollview adjust itself while taking into account the keyboard.
This means that, in the case that I switch into a special data entry, I manually move the scrollview's content so I can view the next element. When I switch from a special entry into a textfield I assume that the previously mentioned code from stackoverflow kicks in and adjust the view. It actually does when I move from the hour data entry (which uses a datepicker in an actionsheet) into the next element which is a textfield. However, when I'm at the date data entry (which is directly before the hour data entry) and press previous to assign the first responder to the textfield above it, the scrollview goes way ahead the text field, like so.
What's important to note is that this problem only occurs when the textfield is not in view. This makes me suspect that I'm incorrectly using the code that readjust the view. For instance, there is a constant in the code that represents the height of the keyboard. I tried changing it from 216 to 260 (so it takes into account my toolbar added on top of the keyboard) but this results in strange black artifacts near the buttom that only occasionally appears.
I'm kind of lost in this bug, and my post is already pretty long. I've prepared an example of my problem in a new project, if any of you could take a look into it I'd be very appreciative.
Here it is

Is there a way to control the NSMenuItem item that is initially highlighted when opening a menu?

I'm working on the details of a symbols pop up button, similar to what Xcode 3 at the top of its editor window.
My controller object is the delegate of the NSMenu that is shown when the NSPopUpButton is shown. I implement the two methods numberOfItemsInMenu: and menu:updateItem:atIndex:shouldCancel: to populate the menu right before it's about to be displayed.
However, the title and image of the selected NSMenuItem have to change each time the user changes the selection in the editor NSTextView, or makes changes to the text; just as is the case with Xcode.
The problem I'm having is when the user goes to click on the NSPopUpButton to display the NSMenu, the selected NSMenuItem and the item that should be selected do not match up, since the menu doesn't have the proper number of items yet.
I'm wondering if there is a way to control which NSMenuItem is initially highlighted and tracked when the user clicks to open the menu. As it stands, the first item it always highlighted and tracked or, if the user had previously selected a item, that item is highlighted and tracked.
I tried explaining as best I could, but here is a image illustrating my problem:
I want the highlighted item to be the same as the selected item when the user opens the menu. Any ideas?
I would use a NSPopupbutton - it can do what you want. maybe you even hide it?
I am not very sure that I understood your problem but If we can add tags to these menu Items.
e.g.
[mMenuItemOne setTag : 1];
[mMenuItemTwo setTag : 2];
[mMenuItemThree setTag : 3];
[mMenuItemFour setTag : 4];}
we can select any Menu item using
[_popUp selectItemWithTag: _selectedItem];
Just a hint not a full solution.
Try to post an NSMouseMoved event to your app right after the menu shown.
Main problem is here to detect the position of the item you want to be highlighted.
Just a starting point.
Have you tried this NSMenuDelegate method:Handling Highlighting
– menu:willHighlightItem:
NSMenuDelegate Protocol Reference
Also you can store the NSMenuItem index in some var to keep track of the selected item for later use.
I'm not sure, do you want to move the mouse selection highlight (the blue stuff) or the checkmark?
In general, the checkmark is the thing you want to change. You can do so from your validateMenuItem: method (or at any other time if your item is set not to take part in validation) using the -setState: method.
The blue highlight is an indicator of the user's keyboard input or mouse location, and you should not mess with it. Changing it does not make any sense, as it would be changed back the moment the user moves the mouse even a single pixel.
That said, you can set the selectedItem of the NSPopUpButton, which will cause the entire menu to be moved so the selectedItem is under the mouse (assuming the mouse just clicked the popup button).
If your menu delegate method is called after the pop up button has decided what item to select, you can't use it. Instead, you could probably set the selectedItem and menu of the popup button from a NSPopUpButtonWillPopUpNotification handler.
If that is also called too late, you'll probably have to subclass NSPopupButtonCell and do it in an override of -attachPopUpWithFrame:inView: (I think that's the spot that should also work when you don't click and just hit the space key while the popup button is selected).

ToolBar on top of keyboard

How can i show toolbar with "Next" and "Previous" buttons on top of the keyboard on iPad like in ShareKit(when logging in)? I have many of text fields, and i need switching between this text fields by using toolbar buttons
Design your toolbar however you prefer, then set it to the InputAccessoryView property of the UITextField whose keyboard it should accompany. It will be automatically displayed above the keyboard whenever it appears.