I have a series of EditTexts for numeric input.
Right now when the user inputs a number in the first field and presses "Enter", focus goes to the next field.
I'd like for the screen input to go away and get back to the main screen layout instead.
How do you achieve this?
Thanks-
Register the key listener on your edit text and handle the enter key event and use the following code to close the soft keyboard
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
Related
I have a textfield which has an ancester (maybe multiple) of type Action, which every one of them has a minimum of one ancestor of type Shortcut.
One intent shortcut defined is the one that catches any of the four arrow key pressed.
I want to execute the default TextField behaviour when arrow key pressed is left or right (move cursor left or right) if certain state is present.
Is there a way, once the CallbackAction is executed?
* I know to execute next CallbackAction for that intent with Actions.maybeInvoke<ArrowKeyIntent>(context, intent) but I don't know how to execute default textfield behavior.
Thank you.
In my winfom program I have a function that change the tabpage when I hit a key.
On tabcontrol indexchanged I check for some parametre and if they are not correct I change the tabpage to the first tab.
If I click on the page with the mouse the tabpage changed to the first tab with the correct content.
If I click a key and run this code "tcOrdre.SelectedTab = tpOrdre;" it changes the tab back to the first but still showing the content of the selected one.
In SelectedIndexChanged is use this code:
MessageBox.Show("Der skal vælges en ordre først"); // Show a messagebox
tcOrdre.SelectedTab = tpOrdreListe; // change tap to first
If I use the mouse then SelectIndexChanged get called when I run:
tcOrdre.SelectedTab = tpOrdreListe; // change tap to first
the SelectedIndexChanged function is called again and the content is okay.
But if I use the key to change index the SelectedIndexChanged does not get called Again and the content never change. Only the tab in the top change to the first one.
I hope someone can help me.
I found the solution.
All I have to do is call this line.
this.BeginInvoke(new Action(() => tcOrdre.SelectTab(0)));
and not tcOrdre.SelectedTab = tpOrdreListe;
And everything Works fine.
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("");
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.
I need to know whether the user is holding down the ctrl key while clicking a button. Since it's a button and not a figure I cannot use 'selectionType' on the figure etc.
How about this:
modifiers = get(gcf,'currentModifier'); %(Use an actual figure number if known)
ctrlIsPressed = ismember('control',modifiers);
The figure class has a number of useful Current* properties which are useful when handling callbacks. This is how to retrieve current mouse position, selected graphics object, and (as here) pressed keys. These include: CurrentAxes, CurrentCharacter, CurrentKey, CurrentModifier, CurrentObject, and CurrentPosition.
Pressing the escape key reinitializes CurrentModifier. My solution so far has been to instruct my users (right in the GUI) to press the escape key to revert to default behavior.
Overall, Matlab's CurrentModifier behavior seems to be that the modifier key "sticks" until one of the following occurs: a different modifier is pressed, a different window is selected, or the escape key is pressed.