Is there a kind of CKeyboardListener for the mouse events? I’m trying to run some code when a user drags a CDockable so that it becomes externalised and I’m not having much luck
There is no global MouseListener. I do not understand what exactly you want to do, perhaps an example could help? When should happen what and why?
Perhaps a DockRelocatorListener?
controller.getRelocator().addDockRelocatorListener( new DockRelocatorListener(){
public void cancel( DockController controller, Dockable dockable ){
System.out.println( "cancel " + dockable.getTitleText() );
}
public void drag( DockController controller, Dockable dockable, DockStation station ){
System.out.println( "drag " + dockable.getTitleText() );
}
public void drop( DockController controller, Dockable dockable, DockStation station ){
System.out.println( "drop " + dockable.getTitleText() );
}
public void init( DockController controller, Dockable dockable ){
System.out.println( "init " + dockable.getTitleText() );
}
});```
The DockRelocatorListener you suggested almost solves my problem as I now can handle the drag of the CDockable. But when you drag the dock back to its original position, it stops being externalized. Is there a way to check if that happens at the end of the drag event? or is it an altogether different event listener?
You can ast after it is dropped. But one does not receive events during the drag & drop operation. There are ways to prevent a dockable from beeing droped onto some stations, but I would need to know what your goal is…
DockStation station ){
System.out.println( "drop " + dockable.getTitleText() );
if( dockable instanceof CommonDockable ){
CDockable cdock = ((CommonDockable)dockable).getDockable();
System.out.println( cdock.getExtendedMode() );
}
}```
I have some buttons associated with the dock that I’m trying to make visible only if the dock is externalised. I created a Action that does that just fine, but I’m having problems doing the same when the dock is externalised or un-externalised by mouse drag. When the user drags the dock, so that it ends up being externalised, I set the buttons to be visible. But if the user dragged the dock so that it snaps back to its original position, the buttons should be made not visible.
Your last piece of code helps me in getting the CDock from the Dockable, but I have to figure a way to test if the dock is still externalised or not, to show or hide the buttons accordingly
Ah, well, how about the CDockableStateListener - which tells when the location of a CDockable changes?
public void externalized( CDockable dockable ){
// now it is externalized
}
public void normalized( CDockable dockable ){
// now it is no longer externalized
}
...
});```
It would be ideal, but the mouse drag does not trigger the listener
I’m terrible sorry, that was a bug in the framework.
Just upgrade to this version and please try the CDockableStateListener again.
The event was internally handled, but I forgot to forward the event to the listeners…
Strange. I just changed the version of the libraries used, and now when I externalise, the dock vanishes. Its strange, because I have other places where I use the framework with these new libraries and it works fine. I tried to test around but I’m not seeing what’s going on. Any clue to what may be happening, as you know all the changes made in this version? I was using the preview_6c before, with no problem.
EDIT: I tried reverting to the preview_6c and it now the docking appears, without changing any of the code, so I guess that confirms that the new version is where the problem lies. Maybe some event conflict or something !?
There were some changes in order to support applets.
Hm, some things to check:
- You use a JFrame for your application?
- You call “new CControl( the_JFrame )”?
- And the frame is not yet visible when you create the CControl?
CControl control = new CControl(new ComponentWindowProvider(this));
I’m using it in a JDialog in my application, where i want to show a table that can be large. The docking helps the user see the table better if the element count if big by allowing it to be detached and resized.
I initialise the elements of the dialog prior to showing it, yes.
I did not test this with JDialog. I’ll test it once I’m at home.
So, the bug was actually “distributed” over two files, hence it took a little while longer to find it.
Dialogs should work now as well: click