Actions
Improvements #14321
open
MS
Clarification WApplication::globalKeyWentDown/Up and WDialog::keyWentDown/Up
Improvements #14321:
Clarification WApplication::globalKeyWentDown/Up and WDialog::keyWentDown/Up
Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
02/10/2026
Due date:
% Done:
0%
Estimated time:
Description
Affected: docs and concept of Wt 4.12.2 (and former versions)
split from Improvements #13791: WApplication::globalKeyWentDown dead as long as WMenu focused by mouse click
Wt::WApplication::globalKeyWentDown()
Event signal emitted when a keyboard key is pushed down.
The application receives key events when no widget currently has focus. Otherwise, key events are handled by the widget in focus, and its ancestors.
Wt::WDialog::keyWentDown()
Event signal emitted when a keyboard key is pushed down.
The event will be triggered if nothing in the WDialog has focus
- Both docs are not exact. "no widget" / "nothing" might mean "no WFormWidget" or some other base class. The events do fire if f.i. a
WTableViewis focused. - In UI frameworks, global
KeyWentDownusually fires on all key presses regardless of the focus (and provides means to intercept keypresses).
One can simulate this to a certain degree by adding the handler to all widgets. This is error-prone, pretty inconvenient and not feasible for e.g.WMenubecause it does not expose such signals. - I see no difference between these signals of
WApplicationandWDialog. Why different names?
Files
MS Updated by Michael Seibt 7 months ago
RM Updated by Romain Mardulyn 20 days ago
- No widget means no
WWidget. If aWTableViewis focused andWApplication::globalKeyWentDown()is emitted, it is a bug (Note that aWTableViewbeing focused has nothing to do with the fact that an element inside theWTableViewis selected). WMenucannot be focussed,WMenuItemare what is being focussed, and that class is inherit fromWContainerWidget, which itself inherit fromWInteractWidget, so you can have aWMenuItemreact to a key pressed when it has the focus. Also, most of what you do not get viaWApplication::globalKeyWentDown(), you can get withWApplication::root()::keyWentDown().
MS Updated by Michael Seibt 20 days ago
Hi Romain,
thank you for the clarification!
I missed WApplication::root()::keyWentDown(). I am switching to it.
Actions