Re: QML Keys.onPressed() cannot capture keypress?

1,775 views
Skip to first unread message

Micke Prag

unread,
Feb 20, 2013, 4:08:03 AM2/20/13
to andro...@googlegroups.com
> First off, thanks for the great work, guys!
>
> Second, I can't seem to capture the back key press in a QML application I'm
> working on. I modified my QtActivity.java according to
> http://stackoverflow.com/questions/9219747/how-to-block-the-back-key-in-android-when-using-qt (but
> changed KEYCODE_MEDIA_PREVIOUS to KEYCODE_ENTER) and I have a
> "Keys.onPressed: { console.log("captured keypress") } in the root item of
> my QML document. Despite that, I cannot seem to get QML to notice the
> keypress. What am I doing wrong (or is this a bug)?
>
> Thanks,
>
> Chris


First off, you need to set the property "focus" on your QML items to receive key event. If you use loaders to load parts of your UI each needs to set this property as well.

Second, it have proposed a patch for handling the back-button from QML. You can find it here:
https://git.reviewboard.kde.org/r/108332/

Still nothing from Bogdan though... :(

Regards
Micke



Chris Konstad

unread,
Feb 21, 2013, 2:20:02 PM2/21/13
to andro...@googlegroups.com
Micke,

Thanks for the quick reply!  It worked great!  I just had to set the focus.

Thanks again,

Chris
Reply all
Reply to author
Forward
0 new messages