You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Mathieu Bouchard (JIRA)" <ji...@apache.org> on 2015/06/01 14:59:17 UTC

[jira] [Comment Edited] (CB-9005) Can no longer use setOnKeyListener on webView in plugins

    [ https://issues.apache.org/jira/browse/CB-9005?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14567269#comment-14567269 ] 

Mathieu Bouchard edited comment on CB-9005 at 6/1/15 12:58 PM:
---------------------------------------------------------------

Ian, I also ended up doing something very similar but instead of a hook, I forked `cordova-android` ;) In my case, I really wanted the B button to fire the `backbutton` event, and ended up changing some of the same files you did: https://github.com/apache/cordova-android/pull/177/files

It would be great to have a general purpose event being fired that just sent us all KEYCODE_* events, something like `android_keyup` and `android_keydown` (mapping to ACTION_UP and ACTION_DOWN) with the KEYCODE_* value as the `keyCode` parameter.


was (Author: matb33):
Ian, I also ended up doing something very similar but instead of a hook, I forked `cordova-android` ;) In my case, I really wanted the B button to fire the `backbutton` event, and ended up changing the same two files you did: https://github.com/apache/cordova-android/pull/177/files

It would be great to have a general purpose event being fired that just sent us all KEYCODE_* events, something like `android_keyup` and `android_keydown` (mapping to ACTION_UP and ACTION_DOWN) with the KEYCODE_* value as the `keyCode` parameter.

> Can no longer use setOnKeyListener on webView in plugins
> --------------------------------------------------------
>
>                 Key: CB-9005
>                 URL: https://issues.apache.org/jira/browse/CB-9005
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, Plugins
>    Affects Versions: 4.0.0
>            Reporter: Ian Darling
>            Assignee: Joe Bowser
>            Priority: Minor
>
> I have a plugin that is used for handling "physical" key down/up events on Android devices with additional buttons - these buttons typically fire off KEYCODE_BUTTON_R1, etc
> In earlier versions of Cordova (3.7.0?) I was able to attach a keyListener in the plugin by doing:
> this.webView.setOnKeyListener(etc);
> In migrating to 4.0.0 this no longer compiles.
> My initial thought was to change to using this.webView.getView().setOnKeyListener instead (which appears to be the right way to do it), but this doesn't seem to fully work - my plugin still gets volume up/down key events (which I disregard), but not events for BUTTON_R1.
> Debugging CordovaLib suggests that CordovaWebViewImpl.onDispatchKeyEvent does receive the BUTTON_R1 events, but I'm at a loss as to how to get them into the plugin itself.
> Is there a workaround or alternate API I should be using?
> Thanks,



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org