Skip to content

Commit 21549c7

Browse files
committed
Fix drag & drop in OSR Kivy when running http://html5demos.com/drag
The drag & drop example from MDN worked fine, but the one at html5demos didn't. There were issues with the type of drag operations being set.
1 parent efdef0e commit 21549c7

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/linux/binaries_64bit/kivy_.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ def devtools(self, *kwargs):
577577
is_drag = False
578578
is_drag_leave = False # Mouse leaves web view
579579
drag_data = None
580+
current_drag_operation = cefpython.DRAG_OPERATION_NONE
580581

581582
def on_touch_down(self, touch, *kwargs):
582583
# Mouse scrolling
@@ -630,7 +631,6 @@ def on_touch_up(self, touch, *kwargs):
630631
if self.is_drag:
631632
#print("on_touch_up=%s/%s" % (touch.x,y))
632633
if self.is_drag_leave or not self.is_inside_web_view(touch.x, y):
633-
print("~~ DragSourceEndedAt")
634634
# See comment in is_inside_web_view() - x/y at borders
635635
# should be treated as outside of web view.
636636
x = touch.x
@@ -642,15 +642,20 @@ def on_touch_up(self, touch, *kwargs):
642642
y = -1
643643
if y == self.height-1:
644644
y = self.height
645+
print("~~ DragSourceEndedAt")
646+
print("~~ current_drag_operation=%s"
647+
% self.current_drag_operation)
645648
self.browser.DragSourceEndedAt(x, y,
646-
cefpython.DRAG_OPERATION_MOVE)
649+
self.current_drag_operation)
647650
self.drag_ended()
648651
else:
649652
print("~~ DragTargetDrop")
650653
print("~~ DragSourceEndedAt")
654+
print("~~ current_drag_operation=%s"
655+
% self.current_drag_operation)
651656
self.browser.DragTargetDrop(touch.x, y)
652657
self.browser.DragSourceEndedAt(touch.x, y,
653-
cefpython.DRAG_OPERATION_MOVE)
658+
self.current_drag_operation)
654659
self.drag_ended()
655660

656661
touch.ungrab(self)
@@ -697,7 +702,7 @@ def on_touch_move(self, touch, *kwargs):
697702
self.is_drag_leave = False
698703
print("~~ DragTargetDragOver")
699704
self.browser.DragTargetDragOver(
700-
touch.x, y, cefpython.DRAG_OPERATION_MOVE)
705+
touch.x, y, cefpython.DRAG_OPERATION_EVERY)
701706
self.update_drag_icon(touch.x, y)
702707
else:
703708
if not self.is_drag_leave:
@@ -720,6 +725,7 @@ def drag_ended(self):
720725
self.is_drag = False
721726
self.is_drag_leave = False
722727
del self.drag_data
728+
self.current_drag_operation = cefpython.DRAG_OPERATION_NONE
723729
self.update_drag_icon(None, None)
724730
print("~~ DragSourceSystemDragEnded")
725731
self.browser.DragSourceSystemDragEnded()
@@ -954,13 +960,15 @@ def StartDragging(self, browser, drag_data, allowed_ops, x, y):
954960
self.browserWidget.is_drag = True
955961
self.browserWidget.is_drag_leave = False
956962
self.browserWidget.drag_data = drag_data
963+
self.browserWidget.current_drag_operation =\
964+
cefpython.DRAG_OPERATION_NONE
957965
self.browserWidget.update_drag_icon(x, y)
958966
return True
959967

960968

961969
def UpdateDragCursor(self, browser, operation):
962-
# print("~~ UpdateDragCursor(): operation=%s" % operation)
963-
pass
970+
#print("~~ UpdateDragCursor(): operation=%s" % operation)
971+
self.browserWidget.current_drag_operation = operation
964972

965973

966974
if __name__ == '__main__':

0 commit comments

Comments
 (0)