I am working on one enterprise app.
In that, I need to open one popup on one shortcut key, which is the combination of Alt+AnyCharKey.
So when I press that key with Alt, for different char keys, different numbers or characters is typed in TextInput.
Suppose If I press Alt+A, it prints 1 in TextInput.
So problem is, when I capture the shortcut key and opens a popup and by setting focus on TextInput of that popup, that number is typed in TextInput.
So how can I disable that Alt+Key combination in TextInput ???
Simple preventDefault on keyDown should help, I think
protected function textinput_keyDownHandler(event:KeyboardEvent):void
{
if (event.altKey)
event.preventDefault();
}
Related
I have a primefaces autocomplete element which works great except one thig. The problem is that when I enter a valid text (which is mappable to the data behind) but I don't select the element from the propositions, and don't press tab or enter, nothing happens.
So I enter a value and click into another field, the element is not selected and the validation fails. However, I don't want the user to force to explicitly select an item.
My ideas were, that i put an onchange listener to the input element and trigger the primefaces itemSelect event within. But I don't know how to do that, if it's even possible.
Or maybe there are other solutions?
Thanks in advance!
I found a way, although it might not be the most beautiful and easy one.
Maybe it helps somebody...
This is a specific solution for primefaces (5.3), but it should work for other versions too.
$('#form\\:txtAutoComplete_input').val('Foo');
$('#form\\:txtAutoComplete_input').trigger('keydown');
$('#form\\:txtAutoComplete_input').trigger('input');
$('#form\\:txtAutoComplete_panel .ui-autocomplete-item').trigger('click');
For some reason, after the value is entered into the input field, you have to trigger the keydown and the input event in that order. After these events the autocomplete list shows with the matching values. There you have to trigger click on a certain element, so all the backing bean stuff is properly executed.
There is an API for Primefaces widgets.
For instance ;
<p:autoComplete id="gtautoaomplet" value="#{item.soemprop}" completeMethod="#{bean_CrossCheckNew.completeText}" scrollHeight="250"/>
In JS code ;
widget_form_mapingGrid_0_gtautoaomplet.search('foo');
When you write "PrimeFaces.widgets" in your browser console you can see all the widgets available in your page.
For more datail :
https://primefaces.github.io/primefaces/jsdocs/index.html
Good luck.
How do I specify which button on the form is the default button which will be pressed when someone presses Enter from anywhere on the screen?
You can't do this in oracle forms with normal functionality.
The only thing you can do if you really want to accomplish this is to re-map your enter key see the following link on how to do this.
Then you can map your enter key to a key-trigger and in that key-trigger you can put the code you want to execute when the enter-key is pressed.
The only downside to this is that in every application the enter key is pressed the same key-trigger will be triggered if it exists in your application. So you can't use this method to only use the enter key in 1 form and normal use (go to the next field) in the other applications. Then you have to make in every application that key-trigger with the code next_item;
I have set the tabindex of TexInput controls in my Adobe Air works fine with tab key. Now I want to do the same with the enter key. I mean when I press enter key in the TextInput, next control should be selected.
In C# we can do the same with SendKeys and as per my knowledge there is not such way in Adobe Air.
Here is my added event
// get key presses only when the textfield is being edited
inputText.addEventListener(KeyboardEvent.KEY_DOWN,handler);
function handler(event:KeyboardEvent){
// if the key is ENTER
if(event.charCode == 13){
// WHAT ???
}
}
Find the instance with next/previous tabIndex
Depending on what control you are using, either call setFocus() method on this control (if it has one), or set the focus property of the stage to this instance. Set it to null if you want to remove focus at all.
In a registration page,i want to move to next field,when i click tab from keyboard.I have implemented ENTER key for submnission,but i cant move to next field when pressing TAB
Setting the tabIndex to sequential values should be enough, maybe tabEnabled too.....
textfieldOne.tabIndex=1;
textfieldTwo.tabIndex=2;
textfieldOne.tabEnabled=true;
textfieldTwo.tabEnabled=true;
I have a method called checkKeyCode(obj) which simply takes the character you type into a textbox and replaces it with its keyCode.
This method is called from onkeydown attribute of textbox input (onkeydown="return checkKeyCode(this)").
The problem is then I want to be able to press tab and focus to the next element. I don't have to know the element's id or name or tag. Basically I want to combine my method's functionality with the default functionality of browser when you press Tab key (which sets focus to the next element in the form).
Can this be done. If so how?
Any help would be greatly appreciated.
Check the keycode in your handler and if the value is 9, it's a tab. Exit your handler if it is and return false.
Also, don't use the onkeydown event. Use onkeyup instead.