Skip to content

Hide keyboard when focus-item invisible #21

@freaksdd

Description

@freaksdd

Compared to Qt's virtual keyboard, the 'CuteKeyboard' is still visible/active when a focused object is set to invisible ('visible = false').
After looking at the source code and trying things out, I came up with the following solution:
Add a connection to the item and it works as intended.
I don't know whether the connection will remain when the new focused input object is overwritten.
I also add hideInputPanel(); to request if(!AcceptsInput). This means, if a button or other focus-items with non-input-methods will be focus.

In VirtualKeyboardInputContext.cpp in setFocusObject(QObject *object)

// existing code
// ...
bool AcceptsInput = d->FocusItem->inputMethodQuery(Qt::ImEnabled).toBool();
    if (!AcceptsInput) {
        hideInputPanel(); // Add hide when no acceptable input-items
        return;
    }
// existing code end

// new Connection
QObject::connect(d->FocusItem, &QQuickItem::visibleChanged, this, [&](){
        if(!d->FocusItem->isVisible())
            hideInputPanel();
        else
            showInputPanel();
    });
// existing code
emit inputItemChanged();
// ...
// existing code end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions