fredsa / gwt-dnd

Library providing easy to use mouse or touch based drag-and-drop capabilities to GWT
42 stars 41 forks source link

No Focus/Blur-Events when making widgets draggable #117

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm using the DnD library within a table were rows are draggable and the table 
itself is focusable.
Everthing works fine, when the table rows are not draggable.
But when calling the AbstractDragController.makeDraggable() method then no 
Focus-/Blur-events are fired anymore!
The reason is the mouse event handler which is registered on the draggable 
widgets, in my case the table rows.
In line 155 of the MouseDragHandler.onMouseDown() method event.preventDefault() 
is called which causes that no other events like the Focus-/Blur-Events will be 
fired.
Uncommenting this line will fix this issue for me, but I'm not sure what other 
side-effects may occur.
I'm using the gwt-dnd library 3.0.1 with gwt 2.0.4.

Original issue reported on code.google.com by m...@censhare.de on 26 Jul 2010 at 8:00

GoogleCodeExporter commented 9 years ago
I think this should be viewed as a defect because in the drag handler class 
there is a behavior setting specifically to set the drag start threshold pixel 
size to >0 to "allow other registered listeners to respond to events" when the 
user is not trying to drag the widgets but is just trying to interact with 
them. So if the design of the library already includes allowing for other 
listeners to remain usable, then this case will go against that design 
principle. The problem is that this issue is preventing forms from being 
draggable, because once they are made draggable they cannot be used as forms. I 
will try the above turn around for now and see if it works in my situation.
Is this is a bug? Are we using  the library wrong? Or if it is a bug, is there 
a better work around than the one suggested above, which would not require 
changing the source code.

Original comment by kor...@gmail.com on 15 Apr 2011 at 2:46

GoogleCodeExporter commented 9 years ago
It sounds like the fact that your focus/blur events are not received is a side 
effect of the preventDefault() call, which we need.

Hopefully setting the drag sensitivity > 0 will help.

Original comment by fredsa@google.com on 21 Jun 2011 at 12:24

GoogleCodeExporter commented 9 years ago
Sorry, but setting the drag sensitivity > 0 doesn't help.
The only workaround I found for this problem is to add a mouse down listener 
and set the focus manually again:
        focusable.addMouseDownHandler(new MouseDownHandler() {
            @Override
            public void onMouseDown(MouseDownEvent event) {
                focusable.setFocus(true);
            }
        });

Original comment by m...@censhare.de on 21 Jun 2011 at 7:50

GoogleCodeExporter commented 9 years ago
Thanks for your response! 

I realized a work around exists which actually solves my problem. The truth is 
that typically people do not want to make an entire panel full of fields 
grabable directly. What is more desirable is to designate an icon on the panel 
which represents the drag handle, and make the panel draggable by dragging that 
icon. This is how almost everything works in all OSs native UIs as well and it 
makes sense. I realized that the gwt-dnd library supports drag handles out of 
the box, and I implemented my form dragging based on using drag handles.This 
leaves all the form functionality intact and it also created a better user 
experience with minimal work. So I found my answer.

Thanks again for the reply.  

Original comment by kcsas...@securezone360.com on 21 Jun 2011 at 1:10

GoogleCodeExporter commented 9 years ago
Please try the jar attached to this comment and let me know if that solves your 
problem:
  http://code.google.com/p/gwt-dnd/issues/detail?id=52#c6

Original comment by fredsa on 31 Jan 2012 at 5:57

GoogleCodeExporter commented 9 years ago
Actually, I'm going to mark this as a dup of issue 52

Original comment by fredsa on 31 Jan 2012 at 6:15