Cannot capture keydown event in a modal

Aperta
#77 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
android, angular, typescript
Ambito
mobile-dev

Direzione di ricerca

Inizia con l'implementazione estesa di dispatchKeyEvent in activity.android.ts e riproduci il problema con un modal non a schermo intero che contiene il dropdown. Confronta la gestione dei tasti nel modal con il caso del componente funzionante e verifica che gli eventi dei tasti freccia possano essere acquisiti e registrati senza compromettere la navigazione del dropdown.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 14
  • Cross-platform modules:
  • Android Runtime: 8.2
  • iOS Runtime:
  • Plugin(s):
  • NativeScript-Angular: 13
  • Angular: 13.2

Describe the bug
I am unable to capture the keydown event in a modal dialog.

The key press is coming from a hardware keyboard, not the onscreen one.

I can accomplish this in any other component using:

application.on('KEYCODE_DPAD_DOWN', (() => {
	console.log('Keyboard Down Arrow Pressed');
}));

And it works fine.

This is after extending activity.android.ts, and adding:

public dispatchKeyEvent(event) {
    let keyCode = event.getKeyCode();

    switch (keyCode) {
        case android.view.KeyEvent.KEYCODE_DPAD_LEFT:
        case android.view.KeyEvent.KEYCODE_DPAD_UP:
            application.notify({
                eventName: 'KEYCODE_DPAD_UP',
            })
            return true;
        case android.view.KeyEvent.KEYCODE_DPAD_RIGHT:
        case android.view.KeyEvent.KEYCODE_DPAD_DOWN:
            application.notify({
                eventName: 'KEYCODE_DPAD_DOWN',
            })
            return true;
        default:
            return super.dispatchKeyEvent(event);
    }
}

I have tried every manner of capturing the keypress in a modal that I could, none work.

To Reproduce
Extend android activity to capture a keypress, try to capture a keypress in a non-fullscreen modal.

Expected behavior
Should be able to capture the keypress and console log it, similar to how it is in a component.

Sample project

Additional context
In my modal, I have a dropdown. If I open the dropdown and then press the up/down arrow keys, it navigates through the selections, so the buttons work in the modal, I just don't know how to capture and console log them.

Please let me know if additional info is required.

Lingua principale
TypeScript
Stelle
55
Fork
13
Merge medio
16m
PR unite (30g)
1

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NativeScript/angular

Tutte le issue di NativeScript/angular

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.