-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I am using ZK 9.1.0 and I want to handle keyboard function keys.
For example I want to use CTRL+Fx to select tabs. It works by using ctrlKeys and onCtrlKey on parent component. But after first try, focus is not anymore on tab's parent component and command is not fired anymore. I can satisfy if I put handling 'ctrlKeys' and 'onCtrlKey' on every inner component but that is too much.
Is it possible somehow to 'transfer' that event to the component (in this case window) which has ctrKeys handling?
How to use:
1. Start fiddle
2. Press CTRL+F3
3. Third tab is selected
4. Without any action press CTRL+F2
Because the focus is lost from the textbox, so keypress doesn't work. You can put focus back to the tabbox by
((HtmlBasedComponent)event.getTarget()).focus();
Clients.focus("tabbox");
in the end of doFireCtrlKeyEvent()
.
Another way is to turn org.zkoss.zk.ui.invokeFirstRootForAfterKeyDown.enabled to true
. (No need to call focus()
)
Asked: 2021-12-07 22:51:47 +0800
Seen: 7 times
Last updated: Dec 14 '21