On dimanche 19 février 2017 10:33:31 CET René J.V. Bertin wrote:
> Hello,
> 
> A while back I ran into a situation where a custom shortcut (F2 for lowering
> the window having focus) also triggered a rename action in KDevelop:
> https://phabricator.kde.org/D1523
> 
> The idea came up on that ticket to provide a central definition for
> shortcuts like that, e.g. KStandardAction::rename . Has such an idea ever
> be considered?

KStandardAction::renameFile(), with default shortcut F2, already exists.
Apparently the naming is a bit too file-manager oriented, but this is the 
standard rename action. This is however totally unrelated to the "also 
triggers" problem you're mentioning. Retitling ;)

> The underlying issue here is probably that the custom KWin shortcut is
> defined through kglobalaccel (on a Plasma4 desktop) and that the keystroke
> isn't eaten but propagated to the (KF5) application having focus. Shouldn't
> it be configurable whether a custom keystroke is propagated or not?

I don't see why this should be "configurable".

I would expect global shortcuts to never propagate to the window with focus.

Let's test.
I ran the test application attached, then typed Ctrl+Alt+K (global shortcut 
for changing the keyboard layout) (this is a better example than Alt+F2 to pop 
up krunner because that steals focus anyway).

Result: the test app shows the keypress events for Ctrl and Alt (obviously),
it does not show the keypress for K (good, this matches my expectation),
BUT when I release K, the app receives a key *RELEASE* event for Key_K.

Martin, is this a bug and is it fixable?

-- 
David Faure, fa...@kde.org, http://www.davidfaure.fr
Working on KDE Frameworks 5
#include <QPushButton>
#include <QApplication>
#include <QDebug>
#include <QKeyEvent>

class MyPushButton : public QPushButton
{
public:
    MyPushButton() : QPushButton(0) {
    }
protected:
    virtual void keyPressEvent(QKeyEvent* ev)
    {
        updateText(ev->key(), true);
    }
    virtual void keyReleaseEvent(QKeyEvent* ev)
    {
        updateText(ev->key(), false);
    }
private:
    void updateText(int key, bool press)
    {
        setText((press ? "PRESS " : "RELEASE " ) + QString::number(key) + " modifiers: 0x" + QString::number(QApplication::keyboardModifiers(), 16));
    }
};

int main(int argc, char** argv )
{
    QApplication app(argc, argv);

    MyPushButton* button = new MyPushButton;
    button->resize(300, 120);
    button->show();

    return app.exec();
}

Reply via email to