On Friday 01 April 2016 14:33:29 Elvis Stansvik wrote: > 2016-04-01 12:45 GMT+02:00 Elvis Stansvik <[email protected]>: > > Hi folks, > > > > I have a full screen, page based Qt Quick 2 application. Input is > > contstrained by the hardware to the Left/Right/Return keyboard keys, > > so is quite limited, and navigation between pages is done using > > buttons on each page which handle return presses using (most of the > > time) Keys.onReturnPressed and navigation between buttons and other > > items with KeyNavigation.left/right. > > > > I now have the need to provide a special global shortcut: On almost > > all of the screens, holding the Enter key for 3 seconds should bring > > the user immediately to a sort of start screen, where he/she can > > choose to go into Settings or Power Off. Kind of like how holding the > > power button on a phone often brings up a power off/flight mode menu. > > > > I'm struggling to find a good way to handle this centrally: since > > Enter presses are normally accepted (swallowed) by my various buttons > > and other input items on the pages, where can I put some central key > > press/release handler in which to start/stop a timer (to determine if > > it was a long 3 sec press or not)? > > > > My pages are FocusScopes stuffed in a StackView inside a Window. > > > > Many thanks for any advice. Has noone had this kind of requirement > > before? (Global "hold key" shortcut). > > Actually, scratch this. Our input device is a pushable wheel, and I've > realized now that we better re-program the Arduino we have hooked up > to it to have the logic to determine "long" vs "short" presses there > instead, and deliver these as distinct keypresses. >
Well this might be the better idea. I don't know enough about Qt Quick since I am doing everything in C++ and widgets. But there I would install an event filter on every page, catching keypress/release for the enter key, but no eating it up. Start a QTimer on press, stop it on release. If it fires, enter was pressed long and this can trigger your global action. Reinhardt _______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
