i would like to ask your help in order to fix a strange behaviour about focusing.
when the browser load a webpage, all my Swing/AWT components will lose focus.
in particular, main menu's shortcuts (JMenuBar) won't work anymore (ie: CTRL+F4 -> quit the app).
I already read some topics related to this specific problem with no success.
indeed, i added the following code in _cefclient.addLoadHandler() => onLoadingStateChange()
- Code: Select all
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
_jframe.requestFocus();
this trick works sometimes only. in my personal opinion this is why:
when the user clicks inside the webview to scroll the webpage, the focus will still stand attached to the webview itself.
that said, you might want to trigger when the user stop interacting with the webview in order to redirect the focus somewhere else.
unfortunatelly i dunno how to catch/implement this type of event/s.
since i tried to figure something out by myself, i wrote this code:
- Code: Select all
Thread t = new Thread(){
@Override
public void run(){
while( true ){
try{
String obj = "" + (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner().toString());
System.out.println( "focus:" + obj );
Thread.sleep(1000);
}catch(Exception idk){
//TODO
}
}
}
};
t.start();
that gives me an important clue: the webview/browserUI doesn't seem to get any focus when the user interact with it. why??? i mean, the component (browserUI) is effectively there and i can attach any Listener to it with no effect. at this point i'm seriously confused.
just to be clear, i don't ask you to code for me.
i would appreciate some suggestions or criticisms (maybe i'm doing something wrong).
obviously if you could also provide some examples, it would be awesome.
thanks ahead time for your help and availability.
-redpillar