changeset 154:b96607c8be7f

Fixed bug that dropping an item onto another would not set the drag_data to the replaced item, which caused this to be lost.
author KarstenBock@gmx.net
date Thu, 06 Oct 2011 16:08:00 +0200
parents 2ba7c6d8f738
children 7214224b8d83
files src/parpg/gui/containergui.py
diffstat 1 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/parpg/gui/containergui.py	Thu Oct 06 16:04:48 2011 +0200
+++ b/src/parpg/gui/containergui.py	Thu Oct 06 16:08:00 2011 +0200
@@ -67,12 +67,8 @@
             # get the up and down images of the widget
             up_image = drag_widget.up_image
             down_image = drag_widget.down_image
-            # set the mouse cursor to be the widget's image
-            self.controller.setMouseCursor(up_image.source, down_image.source)
-            data_drag.dragged_image = up_image.source
-            data_drag.dragging = True
-            data_drag.dragged_widget = drag_widget
-            data_drag.source_container = self.container
+            self.setDragData(drag_widget.item, down_image, up_image, 
+                             self.container)
             container.take_item(self.container, drag_widget.item.slot)
             
             # after dragging the 'item', set the widgets' images
@@ -99,13 +95,18 @@
                     container.put_item(self.container, drag_item, drop_index)
                 )
                 
-            drop_widget.item = drag_item
-            self.updateImage(drop_widget)
             #if there was no item the stop dragging and reset cursor
-            if replace_item == None:
+            if replace_item:
+                up_image = drop_widget.up_image
+                down_image = drop_widget.down_image
+                self.setDragData(replace_item, down_image, up_image, 
+                                 self.container)
+            else:
                 data_drag.dragging = False
                 #reset the mouse cursor to the normal cursor
                 self.controller.resetMouseCursor()
+            drop_widget.item = drag_item
+            self.updateImage(drop_widget)
         except (container.BulkLimitError):
             #Do we want to notify the player why the item can't be dropped?
             pass