mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 22:10:54 +03:00
FlatInspector: add/remove mouse listener in setEnabled
This commit is contained in:
@@ -155,7 +155,7 @@ public class FlatInspector
|
||||
rootPane.putClientProperty( FlatInspector.class, inspector );
|
||||
inspector.setEnabled( true );
|
||||
} else {
|
||||
inspector.uninstall();
|
||||
inspector.setEnabled( false );
|
||||
rootPane.putClientProperty( FlatInspector.class, null );
|
||||
}
|
||||
}
|
||||
@@ -175,8 +175,6 @@ public class FlatInspector
|
||||
}
|
||||
};
|
||||
|
||||
rootPane.getGlassPane().addMouseMotionListener( mouseMotionListener );
|
||||
|
||||
keyListener = e -> {
|
||||
KeyEvent keyEvent = (KeyEvent) e;
|
||||
int keyCode = keyEvent.getKeyCode();
|
||||
@@ -220,12 +218,10 @@ public class FlatInspector
|
||||
keyEvent.consume();
|
||||
|
||||
if( id == KeyEvent.KEY_PRESSED ) {
|
||||
FlatInspector inspector = (FlatInspector) rootPane.getClientProperty( FlatInspector.class );
|
||||
if( inspector == FlatInspector.this ) {
|
||||
uninstall();
|
||||
rootPane.putClientProperty( FlatInspector.class, null );
|
||||
} else
|
||||
setEnabled( false );
|
||||
FlatInspector inspector = (FlatInspector) rootPane.getClientProperty( FlatInspector.class );
|
||||
if( inspector == FlatInspector.this )
|
||||
rootPane.putClientProperty( FlatInspector.class, null );
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -243,12 +239,6 @@ public class FlatInspector
|
||||
};
|
||||
}
|
||||
|
||||
private void uninstall() {
|
||||
setEnabled( false );
|
||||
rootPane.getGlassPane().setVisible( false );
|
||||
rootPane.getGlassPane().removeMouseMotionListener( mouseMotionListener );
|
||||
}
|
||||
|
||||
|
||||
public void addPropertyChangeListener( PropertyChangeListener l ) {
|
||||
propertyChangeSupport.addPropertyChangeListener( l );
|
||||
@@ -280,6 +270,12 @@ public class FlatInspector
|
||||
else
|
||||
toolkit.removeAWTEventListener( keyListener );
|
||||
|
||||
// add/remove mouse listener
|
||||
if( enabled )
|
||||
rootPane.getGlassPane().addMouseMotionListener( mouseMotionListener );
|
||||
else
|
||||
rootPane.getGlassPane().removeMouseMotionListener( mouseMotionListener );
|
||||
|
||||
// add/remove window listener
|
||||
if( enabled ) {
|
||||
window = SwingUtilities.windowForComponent( rootPane );
|
||||
|
||||
Reference in New Issue
Block a user