Fixed grabFocus to work when a parented Display is first shown.
This commit is contained in:
parent
4ff2240b57
commit
59a9a970b9
|
@ -270,15 +270,10 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
parent.addFocusListener(parent_focus_tracker = new FocusAdapter() {
|
||||
public void focusGained(FocusEvent e) {
|
||||
parent_focused.set(true);
|
||||
|
||||
// This is needed so that the last focused component AWT remembers is NOT our Canvas
|
||||
WindowsDisplay.this.parent.setFocusable(false);
|
||||
WindowsDisplay.this.parent.setFocusable(true);
|
||||
|
||||
// Clear AWT focus owner
|
||||
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
|
||||
clearAWTFocus();
|
||||
}
|
||||
});
|
||||
clearAWTFocus();
|
||||
}
|
||||
grabFocus();
|
||||
} catch (LWJGLException e) {
|
||||
|
@ -397,6 +392,15 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
private static native void setForegroundWindow(long hwnd);
|
||||
private static native void setFocus(long hwnd);
|
||||
|
||||
private void clearAWTFocus() {
|
||||
// This is needed so that the last focused component AWT remembers is NOT our Canvas
|
||||
WindowsDisplay.this.parent.setFocusable(false);
|
||||
WindowsDisplay.this.parent.setFocusable(true);
|
||||
|
||||
// Clear AWT focus owner
|
||||
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
|
||||
}
|
||||
|
||||
private void grabFocus() {
|
||||
if ( parent == null )
|
||||
setFocus(getHwnd());
|
||||
|
|
Loading…
Reference in New Issue