Cannot capture keypressed event in modal on Android
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Bug
- Klarheit
- Muss geklärt werden
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- android, angular, typescript
- Bereich
- mobile
Rechercherichtung
Beginne mit der erweiterten activity.android.ts und dem nicht bildschirmfüllenden Modal, das in den Reproduktionsschritten beschrieben ist. Verfolge, wie sich dispatchKeyEvent und Anwendungsbenachrichtigungen verhalten, wenn das Modal und sein Dropdown geöffnet sind, und überprüfe anschließend, ob Hardware-Pfeiltastenereignisse im Modal erfasst und protokolliert werden können.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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: 8.2.0
- Cross-platform modules:
- Android Runtime: 6.3.1
- iOS Runtime: N/A
- Plugin(s):
- NativeScript-Angular: 8.2.1
- Angular: 8.2.0
Describe the bug
Same as title, 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.
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.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 55
- Forks
- 13
- Ø Merge
- 16 Min.
- Gemergte PRs (30 T.)
- 1
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus NativeScript/angular
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
NativeScript/angular#170 · 1 Kommentar ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
NativeScript/angular#164 ·
-
My types are gone Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 45/100
NativeScript/angular#163 · 1 Kommentar ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 38/100
NativeScript/angular#158 · 1 Reaktion ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 35/100
NativeScript/angular#155 ·
Alle Issues in NativeScript/angular
Ähnliche Issues
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
-
check:passed streams:add
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100