Bug #14473
openWDialog positioned aside widget incompletely handles focus
0%
Description
Affected: WDialog::positionAt(WWidget*, Orientation) of Wt 4.13.0 (and former versions, checked down to 4.11.4)
Keyboard events still go to the main application (to both the global handlers and to the previously focused widget)
As long as the dialog is popped up using WDialog::positionAt(const WMouseEvent&), it works well - but only until WDialog::positionAt(WWidget*, Orientation).
A WFormWidget like WLineEdit can always be focused and used. But keyboard input does not invoke the connected handlers.
Files
MS Updated by Michael Seibt 7 months ago
"But keyboard input does not invoke the connected handlers."
Correction: This last statement was incorrect. Actually, two widgets receive the keyboard events.
STR:
- run attached main.cpp
- hold
Ctrland right click into a table cell of the firstWTableView
--> AWDialogpops up at the mouse position as intended. - press
Escape
--> "ed.keyWentDown 27 focused" is traced and popup is closed as intended. - press
Space
--> AWDialogpops up below the cell as intended. - press
Escape
--> "ed.keyWentDown 27 focused" is traced and popup is closed as intended.
But also "tv.keyWentDown 27" is traced. Wrong. - hold
Ctrland right click into a table cell
--> AWDialogpops up at the mouse position as intended. - press keys
--> Each time both "ed.keyWentDown focused" and "tv.keyWentDown " is traced. Broken. Does not recover.
RM Updated by Romain Mardulyn 7 months ago
- Related to Feature #14494: Use css anchor for WWidget::positionAt() added
MS Updated by Michael Seibt 3 months ago
The initial STR do not reproduce the bug with Wt 4.14.0/1 in an up-to-date Firefox.
new STR (a):
- right click into a table cell
- right click again into any table cell (without closing the popup before)
new STR (b):
- left click a table cell
- hit
Space - left click again into any table cell (without closing the popup before)
- hit
Space
workaround: call setFirstFocus after both WDialog::positionAt overloads
(works despite Bug #14730: WDialog::setFirstFocus ignores footer and does not focus the WDialog as fallback for this main.cpp, but not completely in a more complex application)
RM Updated by Romain Mardulyn 3 months ago
Hi Michael,
I don't see what is going wrong in your example. When you right click into the table the first time, the WDialog gets the focus, as it should because you connected the shown event to setFirstFocus . Then when you move the WDialog by right clicking on another table cell, the dialog is not being hidden, so shown is not emitted, but your focus was lost due to clicking outside of the WDialog.
MS Updated by Michael Seibt 3 months ago
Hi Romain,
as positionAt automatically shows the dialog including focusing the first time, one could have the expectation that this also happens on later invocations.
Taking positionAt literally, I can agree with you.
I have already overridden / overloaded positionAt and setHidden and finally managed the focus handling.
So this issue can be considered resolved.
Possible improvement: declare void positionAt(const Wt::WMouseEvent& rcMouseEvent) as virtual, so that it can be overridden instead of just overloading again.