Send a Qt::Key_Back key on the back button instead of the Qt::Key_Close key.

Review Request #108332 - Created Jan. 10, 2013 and updated - Latest diff uploaded

Information
Micke Prag
android-qt
beta2
Reviewers
necessitas
Send a Qt::Key_Back key on the back button instead of the Qt::Key_Close key.
    
This makes it much easier to control the behavior of the back button.
For example this code can be used in a QML application to implement back button control.

Item {
    focus: true
    Keys.onBackPressed: {
        if (shouldHandleBackButton()) {
            doHandleBackButton()
        } else {
            // Close the application, default behaviour
            event.accepted = false
        }
    }
}

Basically it emits a Key_Close key event on the back button. If no one accepts it the current top level widget gets the close event as before. This can also be implemented in a non QML application in a similar way by subclassing QWidget::keyPressEvent() and calling QEvent::accept() on the event.
Tested on Cube U30GT
Loading...