Extjs virtual keyboard - keyboard

I am using ExtJs virtual keyboard
Ref:
http://efattal.fr/extjs-dev/examples/virtualkeyboard
I want to fire an ajax request on press of "enter" key of the virtual keyboard.
Is there any way to capture the "Enter" key press event ?
Thanks!

i was facing same problem. try dis
listeners: {
keypress: function(keyboard, keyValue){
if(typeof console != 'undefined')
console.log(keyValue);
if(keyValue=="\n")
{ //your code here }
}
}

Related

Android Compose Faking Keyboard for specific textfields

I have a screen where some textfields I want to show a 'fake' keyboard. The keyboard should be able have as many buttons as I like and be displayed however I want. Just as shown below.
My question then is how do you accomplish something like this?
Is it possible to somehow override the interface to the keyboard so you consume the input and can display a 'fake' keyboard. And then remove the 'fake' keyboard when clicking on the back button on any other textfield which uses the normal keyboard.
Or do I have to create a custom #Composable or TextView with custom callbacks, and also render the text cursor manually?
You can implement your own TextInputService or provide null to completely disable the default input service:
CompositionLocalProvider(
LocalTextInputService provides null // or myTextInputService
) {
TextField(
value = text,
onValueChange = { text = it },
)
}
where myTextInputService is something like:
TextInputService(object : PlatformTextInputService {
//TODO implement methods
}

Which HID key code to use for KEYCODE_BACK button mapping?

Platform:
STB Xiaomi Mi Box S 4
OS Version:
Android Version 9
Issue description:
I want to use the USB keyboard gadget to control the box. I mapped the remote controller buttons (arrow buttons/select/home) into corresponding HID key codes following the page. However, none of the specified/corresponding key codes (0x00f1, 0x009e) for the KEYCODE_BACK button is working as expected.
Question:
Do you maybe know which HID key code should be used for the BACK button?
Appreciated any help!
I found detailed document about HID usages. I hope you can find your answer from the pdf.
PDF: https://usb.org/sites/default/files/hut1_21.pdf
You may use the following code to determine if the Key is Back / Menu on the Android device / key code
if ((event.getKeyCode() == KeyEvent.KEYCODE_BACK || event.getKeyCode() == KeyEvent.KEYCODE_MENU || event.getKeyCode() == KeyEvent.KEYCODE_BUTTON_MODE) && event.getRepeatCount() == 0) {
if( onBackPressed() ) { // function to determine if we should block the action in your code and do something else return true if you want to proc
return true;
} else {
// let the Android system handle the back button
return false;
}
}

kendo ui angular grid - how to leave row when user hits enter key instead of clicking off of row

Ive got a working grid, using in-line editing thanks to this example
https://www.telerik.com/kendo-angular-ui/components/grid/editing/editing-row-click/
What I need to do now, is force the saving upon a user hitting the enter key, instead of clicking away onto another row or away from the current row. I suppose I could add a "save" button in the header?
You could probably use cellClose event in your html (cellClose)="cellCloseHandler($event)" - API Documentation
You could then write your own code (in typescript) in cellCloseHandler() to modify and save the updated items accordingly.
From Kendo UI for Angular Documentation:
In-Cell Editing
You could capture the Enter key hits and force executing cellCloseHandler() like that:
#HostListener('keydown', ['$event'])
public keydown(event: any): void {
console.log("keydown event", event);
if (event.keyCode === 13) {
this.cellCloseHandler();
}
}
Similar to Giannis answer but with small modifications:
Add keydown event to kendo-grid tag.
Call grid.closeCell() instead of calling the closeHander directly.
Template
<kendo-grid #grid
[data]="data$ | async"
(cellClose)="cellCloseHandler($event)"
(keydown)="onKeydown(grid, $event)"
>
Class
onKeydown(grid: GridComponent, e: KeyboardEvent) {
if (e.key === 'Enter') {
grid.closeCell();
}
}
cellCloseHandler(args: CellCloseEvent) {
const { formGroup, dataItem } = args;
// save to backend etc
}
Calling grid.closeCell(); will make the grid to call cellCloseHandler
You dont have to implement a HostListener for Keydown by yourself. If you set the input navigable to true, the cellClose event will get triggered when pressing Enter while editing a cell or row. This way you get the data of the row in your cellCloseHandler aswell for saving it.
<kendo-grid [navigable]="true" (cellClose)="cellCloseHandler($event)"></kendo-grid>

How to listen to key press repetitively in Dart for games?

I know that you can listen to key press and down events with Dart like:
var el = query('#el');
el.on.keyDown.add((e) {});
But the problem here is that it fires only once. I want repetition.
So, I tried keyPress instead, but it has a slight delay before the repetition. I am working on a game and I want it to fire instantly and repetitively.
First of all, don't listen to keyPress events, because the "initial delay" depends on the operating system configuration! In fact, keyPress events may not even fire repetitively.
What you need to do is to listen to keyDown and keyUp events. You can make a helper for this.
class Keyboard {
HashMap<int, int> _keys = new HashMap<int, int>();
Keyboard() {
window.onKeyDown.listen((KeyboardEvent e) {
// If the key is not set yet, set it with a timestamp.
if (!_keys.containsKey(e.keyCode))
_keys[e.keyCode] = e.timeStamp;
});
window.onKeyUp.listen((KeyboardEvent e) {
_keys.remove(e.keyCode);
});
}
/**
* Check if the given key code is pressed. You should use the [KeyCode] class.
*/
isPressed(int keyCode) => _keys.containsKey(keyCode);
}
Then depending on what you do in your game, you probably have "a game loop" of some sort, in your update() method that gets called in every once in a while:
class Game {
Keyboard keyboard;
Game() {
keyboard = new Keyboard();
window.requestAnimationFrame(update);
}
update(e) {
if (keyboard.isPressed(KeyCode.A))
print('A is pressed!');
window.requestAnimationFrame(update);
}
}
Now your game loop checks repetitively for A key pressing.

In Lwuit, How to handle Keypad navigation Events?

In the application I'm building I have Tabs and a list in for each Tab. the behavior I want is when I press the Left/Right Nav Key the selected Tab will change. when I press the Up/Down Nav Key the List will change selection index.
I used LWUIT GUI builder to generate StateMachine/StateMachineBase class.
I've been trying to fix this all day. please help.
Pheromix's answer is correct but he didn't account for the UIBuilder. To override the Form creation in the UIBuilder override the method:
protected Component createComponentInstance(String componentType, Class cls) {
if(cls == com.sun.lwuit.Form.class) {
return new MyFormSubclass();
}
return super.createComponentInstance(componentType, cls);
}
There is an option to override the Tab selection behavior but to get the most accurate behavior this might be the best approach.
Why do you complicate your life ? Just use keyReleased method implementation in your class. Make a test :
if (display.getGameAction(keyCode) == Display.GAME_LEFT || display.getGameAction(keyCode) == Display.GAME_RIGHT)
{
if (tab.getSelectedIndex == 0)
tab.setSelectedIndex(1);
else
tab.setSelectedIndex(0);
}
else if (display.getGameAction(keyCode) == Display.GAME_UP || display.getGameAction(keyCode) == Display.GAME_DOWN)
{
if (list.hasFocus())
super.keyReleased(keyCode);
}

Resources