[[HomePage]] > [[SoftwareIndex|Software Index]] > [[SoftwareDevelopment|Development]] > [[gtkdialog|gtkdialog]] > [[gtkdialogDocTips|Tips and Tricks]] ====9.7 Drag'n drop==== Gtkdialog has limited support for drag'n drop. This is what we've learnt by now: **Drag from file browser to #### widget.** %%(language-ref) export test=" Drag a directory from Rox " gtkdialog -p test %% **Move items in list by drag'n drop.** ([[http://www.murga-linux.com/puppy/viewtopic.php?t=107816 More info in this thread]]) Using the reorderable option in the #### has some strange behavior. For example will items get swallowed when moving them onto another item. The workaround restores the list if the user moves item onto, instead of in between 2 other items... This code by [[MochiMoppel]] is a result of 2 cracked nuts: 1. When moving an item in the list the ##PTR_Y## variable returns 0. A return value greater than 0 tells us that the user is clicking rather than moving. 2. Normally all ####s defined for a widget are processed __before__ built-in actions. The trick is to process a user defined #### __after__ a built-in action. An invisible button allows the code to run a user defined save action __after__ a built-in reorder action. Code below line 12 (##break## command) is activated when user move item in list %%(language-ref) ls -1 /usr/share/backgrounds > /tmp/test do_something () { Xdialog -info "Do something with\n$TREE" x 2000 ;} ; export -f do_something echo ' cat /tmp/test /tmp/test TREE 300200 do_something & break: save:TREE activate:BTN_SAVE ' | gtkdialog -s %% **Move items in list by drag'n drop - OLD SOLUTION.** For the record, we keep the old solution for this task... %%(language-ref) move (){ PRESS_EVENT=$(cat /tmp/PRESS_EVENT) [[ $PRESS_EVENT && $TREE || exit #exit if at least one of the 2 values is empty [[ $PRESS_EVENT == $TREE && exit #exit if both are equal (=single or double click) sed -i "/$PRESS_EVENT/d; /$TREE/ i\\$PRESS_EVENT" /tmp/list #remove PRESS_EVENT, then insert item PRESS_EVENT before item $TREE } export -f move ls -1 /usr/share/backgrounds > /tmp/list export test=" cat /tmp/list TREE 300200 echo \$TREE > /tmp/PRESS_EVENT move refresh:TREE " gtkdialog -p test %% ===@@**#%[[gtkdialogDocTips9.6|❰❰❰ Previous]]#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips9.8|Next ❱❱❱]]#%**@@=== ---- ==Categories== CategoryGtkdialog