Can I not remove the return key on the keyboard? Or at least change its text to "Set"? - iphone

I am creating a sign up page for my iphone app and am having some problems making the way the input views work for the different kinds of fields consistent. The fields are listed as cells in a table view and the editing is supposed to take place directly in the table by having appropriate input views sliding up from the bottom.
Let me focus on only two of the fields here, namely the username field and the birthday field: for the username field it makes sense to have an ASCII capable keyboard sliding up when the user presses the field whereas a date picker seems more useful in the birthday field case.
For both the keyboard and the date picker the cancel button could be located in a tool bar just above the input view. But what about the set button? If I put that in the toolbar as well I need the return key in the keyboard to go away! But that is not possible is it?
If the return key cannot be removed then I might have to live with the set button in the toolbar only in the birthday case and then use the return key as the set button in the username case - but can I then at least change the text on the return key to "Set"?

No it's not possible* to hide the "Return" key.
It is not possible to set the string to "Set" either, but could use the .returnKeyType property to change it to a limited set of strings.
theTextField.returnKeyType = UIReturnKeyDone;
(* Well you could put an opaque UIView directly above it but it's a very bad practice and generally breaks if the user chooses a different input method)

Related

XCode UITest will not give NSTextField keyboard focus

So I have a window appear by clicking on a menu item. Normally the the first textBox would gain immediate keyboard focus, but in the UITest nothing in the window gains keyboard focus (no focus ring). This is problematic becuase it stops me from typing into the textfield with textField.typeText("someText")
I have tried .click() on the window and on the textbox to try and give it focus but nothing seems to bring the window or textbox in focus.
Any help will be greatly appreciated
Example
MainMenu().menuItemForWindow.click() // Opens window
app.windows["windowTitle"].textFields["textBoxId"].click() // Clicks but field does not gain focus
app.windows["windowTitle"].textFields["textBoxId"].typeText("SomeText") // Is not typed into the textField
As a side note, I have verified that all the elements I am querying do actually exist.
EDIT:
I have gotten it to work by literally spamming typeText() until it changes the value of the given text box with something like
if let oldValue = textbox.value as? String {
var newValue: String? = oldValue
while newValue == oldValue {
textbox.typeText("a")
newValue = textbox.value as? String
}
//If we get here then we have edited the text box
textbox.typeText(XCUIDeleteKey) // Get rid of spam text
//TYpe what I want
//...
}
However this method is hacky and I can't really put a time out except from heuristics (roughly 15-30s) so I was hoping someone could help explain a better way of ensuring focus on the textbox or at least an explanation of what I am doing wrong originally. Any help would be greatly appreciated.
Here are two possible ideas for you:
Assign an Accessibility Id to the object you are trying to interact with, and try addressing it via the Accessibility Id. From https://blog.metova.com/guide-xcode-ui-test:
For element identification there is additionally elementMatchingPredicate(NSPredicate) and elementMatchingType(XCUIElementType, identifier: String?).
These are separate from containingPredicate(NSPredicate) and containingType(XCUIElementType, identifier: String?) which are checking the element for items inside it whereas the elementMatching... options are checking the values on the element itself. Finding the correct element will often include combinations of several query attributes.
Enable Accessibility in the System Preferences | Accessibility as described here: https://support.apple.com/en-us/HT204434 and then send keyboard commands to set your focus.

How to clear a SAPUI5 input field with only value help input allowed?

my SAPUI5 app has an input field where the valid values must be obtained through a value help:
<Input showValueHelp="true" valueHelpOnly="true"
valueHelpRequest="onValueHelpRequest"
value="{myModel>/myField}"
The value help is realized with a SelectDialog, where the only options are
choose one or
cancel
The problem is now the following flow:
User opens value help dialog to choose one item and presses Confirm
Input field now displays chosen value
User wants to clear the input, because it's optional
Unfortunately,
sap.m.Input doesn't provide a clear button
sap.m.SelectDialog doesn't provide the possibility to add a custom button like Clear
The input is layed out in a SimpleForm with 2 columns, labels and input fields, so it would be hard to add a clear button
The Gateway entity set which feeds the value help dialog list doesn't have a totally empty line
I don't like the workaround to switch the SelectDialog to multiSelect just for the purpose that the user can choose "one or none". I also think it would be hard to explain to the user "if you want to remove the value, hold the control key and click on the previously selected item again".
Any ideas out there how to easily implement a clear button or something similar?
valueHelpOnly="false"
// with this user can either fill by F4 (assisted input) or by typing input..
and if you want to clear you can add a button and set the value to null
oInput.setValue("");

How to stay focused on form field?

I have a form with multiple inputs and buttons for the user. At the start, only the first input is enabled and a few of the buttons.
When the first input is entered, (when the user presses enter), if there is no input or if the input is invalid, then I want the focus to stay on the input field. But when i try using MyControl.setFocus(), the focus is not staying on the field.
How is it possible to keep focus on the same field in this situation?
Using setFocus in the modified method of a form control is a no-go, as it confuses AX tab order.
You could make the conditional setFocus call from the enter method of the next field control.
It is not bullet proof, back tab is not handled, but is might do it for you.
The invalid case should be handled by the validate (or better validateField if a bound field), method of the first field.
Also consider setting the Skip property on display only fields.
You can return false from the modified() method (AX 2012 R3) and this too seems to prevent the focus from leaving.

Entering text-data into a Table cell, without having a UITextField in each cell

I would like to let the user fill in some data to be submitted.
So I have a table with 7 cells, each of them are labeled so they know what data goes into the field.
I though about putting a UITextField in each cell, but it looks like its out of place and the user can enter up to 255 chars, so also it doesn't display the data so nicely.
Can anybody recommend a good way to handle this kind of thing, whats the best solution in your experience?
Maybe hiding the UITextField after they are done entering data and display the data in some other manner?
Kind Regards,
-Code
You can customize a UITextField in several different ways to make it not look out of place to you: things such as location, size, alignment, font, font size, background color, and etc. You can have the text field appearance change depending on whether the text field is in the selected table row or not.
You can also have a UITextField delegate pre-check any changes to the text field, and prohibit entering a text length greater than some number of characters, or illegal/unwanted characters, etc.

UITextField SecureTextEntry field changes the keypad from numberpad to generic keypad

I have a textField created in IB. I have set the keypad type to Numeric Pad in IB.
When i make secureTextEntry = YES in -(void)textFieldDidBeginEditing:(UITextField *)textField method , my keypad changes from numberpad to generic keypad. I even tried to make the keypad to be numeric programatically but still it doesnot changes.
I have set it like this
-(void)textFieldDidBeginEditing:(UITextField *)textField{
if(textField == self.activationCodeTextField){
self.activationCodeTextField.secureTextEntry = YES;
self.activationCodeTextField.keyboardType = UIKeyboardTypeNumberPad;
}
}
FYI,
I cannot set the textField to be secure in IB because i have an hint text like "4-digits" displayed to the user in the textfield till he starts typing in the text filed. Once he starts typing in the textfield, i want the entries to be a secure text so that it displays only * instead of actual characters he types.
Can you please let me know whats wrong in what I am doing?
I also have two more query
I have a textField where i have some default text (like hint text). I want this hint text to be displayed to the user till the moment he starts typing. I dont want to clear this text when the user clicks on the textfield and then the default text clears away. but, i want this text to be displayed till the moment he actually starts to type something on the keypad, then the default must be cleared and then the actual typed in text to be displayed on the textfield. IS it possible to acheive this ?
Is it possible to set the cursor position of textfield to the first character programatically. This is needed because, i have some default text (hint text) and the cursor is at end of the text. I want the cursor to be at the start of the text. How to make this possible programatically?
Have you tried using -setPlaceholder: on your UITextField? That way you wouldn't need to do put text in the text field, and then later manually convert it to be secure. e.g.
- (void)viewDidLoad {
...
[textField setSecureTextEntry:YES];
[textField setPlaceholder:#"4-digits"];
...
}
That will completely take care of your last two questions. Regarding the first, though, I'm not sure if you can have a numeric keyboard for a secure UITextField or not. It would seem that you can't if setting it programmatically has no effect.