How to determine which dockable is selected

Hi Beni,

I’ve found some small bug or inconsistency in DF. I’m using a CFocusListener on each dockable to determine if it got selected or deselected. This works most of the time, except in one case.

Say, I have 3 stacked dockables and the size of the window is not large enough to display all dockables in the dock title -> the overflow menu is visible and contains the two docks which could not be displayed.
If I click on the Overflow menu, the current dockable doesn’t get the focus and doesn’t get selected.
If I choose one of the dockables from the Overflow menu, the dockable is shown but again not selected.
If I click on any shown dockable the events are fired correct.

Could you please check, what wrong there?
Or is there an other way to determine or to get informed which dockable got selected and deselected?
I need this functionality to keep track of the selected and deselected dockables.

I’ve tried it with the latest DF version 1.1.2p2b and version 1.1.2p1h.

Here is how I use the CFocusListener (only as example):

DefaultSingleCDockable dock = (DefaultSingleCDockable)cControl.getSingleDockable(dockID);

dock.addFocusListener(new CFocusListener() {
    @Override
    public void focusLost (CDockable paramCDockable) {
	fireDeselected(dockID);
    }

    @Override
    public void focusGained (CDockable paramCDockable) {
	fireSelected(dockID);
    }
});

Greetz,
Thomas

The menu belongs to the parent StackDockStation, and if you click on it the parent gets the focus.

For what do you need this information? Or maybe a CDockableLocationListener is what you need (it tells when a CDockable gets visible or invisible)?

Hi Beni,

I need to track or redirect the selected events because one of our applications has a lot of views. If there is a data change the views will be updated. This can be very time consuming so only visible views should be updated. If an invisible view is made visible the view should do the update.

I have tried the location listener, seems to work fine with one little exception. If I select a dockable from the overflow menu which is not visible, the view is made visible but no event is fired.

If you could fix this, my problem would be solved.

Thanks in advance.

Looks strange, clicking on a tab or in the menu should trigger the same code… I’ll have a closer look during the weekend, why the LocationListener is not triggered when you select something from the overflow menu.

The whole issue was caused by a listener that was not properly added to the StackDockComponent (I did write “removeStackDockComponentListener” instead of “addStackDockComponentListener”…). In the next version both the Location-Listener and the Focus-Listener will be triggered when using the menu.

I’ll upload the new version tomorrow (3.February), because I have another open issue to resolve (completely unrelated to this bug).

Hi Beni,

sounds great, thanks for the fast response and bug solving :slight_smile:

Looking forward to test the new version.

Hi Beni,

I’ve tried the new version 1.1.2p2c, but it seems not to work.

If I download DF I get a zip with the name df_1.1.2p2b (1).zip and there are no entries in the changelog for 1.1.2p2c.

Could you please check if this is the correct zip.

I have put up the wrong link… :o the website is now correct.

click here for direct download

It works like charm now. Great :slight_smile:

Thanks.