views:

281

answers:

2

I have a composite widget that contains a disabled TextArea on an AbsotutePanel. Now I want to be able to drag the composite widget, starting from anywhere on it, including the disabled text area.

Is that possible?

A: 

If you want to drag a composite widget, you need to have a reference to the "drag handle" wich is one of the elements in the composite widget that implements HasAllMouseHandlers. The easiest (and in my mind, cleanest) way to do this is to have the composite widget extend the interface HasDragHandle wich requires the composite to have the method: Widget getDragHandle(); the interface does not explicitly tell you so but the returned widget must be a widget implementing the HasAllMouseHandlers interface (or you'll get a runtime error).

(Non-composite widgets implementing HasAllMouseHandlers can be used directly)

I'd reccomend using a Label as a drag handle (it doesn't need to contain any text it could just be styled so the user understands it can be used for dragging), and not a form element because then you're overloading it's behaviour in a way the user most likely won't expect. I'm not really sure how a disabled element would work as a drag handle, quite possibly disabling an element will stop any mouse listners from working to so it won't work as a drag handle (haven't tried it though).

Stein G. Strindhaug
The problem is *disabled* elements don't accept mouse events. I know how to get DnD working otherwise.
lbp
Then the answer is probably: no, you can't drag and drop disabled elements. If it's really important to (apparently) move disabled elements you could make an transparent absolutely positioned element above the form element and use that as a "click catcher" (wrapping this as a composite)
Stein G. Strindhaug
BTW: the transparent element probably should be an element with 0.01 opacity to be sure it is clickable.
Stein G. Strindhaug
A: 

Or, try putting your widget into a FocusPanel, which is already enabled for drag 'n drop anyway. I've done this with a TextBox and a button, and it seems to work fine. Disabling the widget inside of the FocusPanel also keeps it from accidentally being activated.

David Park