Tip: How to detect that a View was Detached
Here is a question that I got on a post about detached views:
“How can I detect that a View has been detached from the main window? I would like to adjust the view’s behavior in that case.”
There is no API to obtain that information directly. However it is possible to do this with a few tricks:
- detached views have an empty window title (i.e. shell.getText().length() == 0)
- when a view is detached resize events are fired
Armed with that knowledge we can detect that a view is detached / reattached. The snippet below shows how (tested on windows).
PS: Our eclipse support helps developers use their time efficiently by providing prompt answers to questions like this one.
Stay Updated with Our Latest Articles
Want to ensure you get notifications for all our new blog posts? Follow us on LinkedIn and turn on notifications:
- Go to the EclipseSource LinkedIn page and click "Follow"
- Click the bell icon in the top right corner of our page
- Select "All posts" instead of the default setting