Here is some code where i did something close. Put this on the propertyChange of the rootContainer on the window you want to collapse/expand.
from javax.swing import SwingUtilities
from java.awt.event import AWTEventListener, MouseEvent
from java.awt import AWTEvent, Toolkit, MouseInfo
from java.awt import IllegalComponentStateException
from java.awt.dnd import DragSourceMotionListener, DragSource
from com.inductiveautomation.ignition.client.util.gui import IgnitionSwingUtilities
from com.inductiveautomation.factorypmi.application import FPMIWindow
class GlobalMouseListener(AWTEventListener):
def __init__(self, container):
self.container = container
def startup(self):
Toolkit.getDefaultToolkit().addAWTEventListener(self, AWTEvent.MOUSE_EVENT_MASK)
Toolkit.getDefaultToolkit().addAWTEventListener(self, AWTEvent.MOUSE_MOTION_EVENT_MASK)
def shutdown(self):
Toolkit.getDefaultToolkit().removeAWTEventListener(self)
def isMousePointInPanel(self, point):
x = point.x
y = point.y
location = self.container.getLocationOnScreen()
cx = location.getX()
cy = location.getY()
cw = self.container.getWidth()
ch = self.container.getHeight()
return x <= cx + cw and x >= cx and y < cy + ch and y >= cy
def handleEnterExit(self, point):
if self.isMousePointInPanel(point):
# here is where your expand logic goes
print 'Mouse in Panel'
pass
else:
# here is where the contract logic goes i would set a contracted flag here to save time.
print 'Mouse not Panel'
pass
def eventDispatched(self, event):
try:
point = event.getLocationOnScreen()
container_window = IgnitionSwingUtilities.getAncestorOfClass(FPMIWindow, self.container)
if event.getID () == MouseEvent.MOUSE_MOVED:
self.handleEnterExit(point)
except IllegalComponentStateException:
pass
if event.propertyName == 'componentRunning':
if event.newValue:
listener = GlobalMouseListener(event.source)
listener.startup()
event.source.putClientProperty('global_listener', listener)
else:
listener = event.source.getClientProperty('global_listener')
listener.shutdown()