How to reorder lines in a grouped list field (workaround)
zryip theSlug
zryip.theslug at gmail.com
Fri Nov 12 17:40:30 EST 2010
Dear List,
For reordering lines in a list field, André Bisseret uses an
adaptation of the Eric Chatonet tutorials:
http://www.sosmartsoftware.com/?r=telecharger&l=en&arch=tutorials/Managing%20Drag%20and%20Drop2.rev.zip
and
http://www.sosmartsoftware.com/?r=telecharger&l=en&arch=tutorials//List%20reorganizing.rev.zip
The script works like a charm for a list field, but stop working if
the list field is grouped.
Not checked myself because I have no account, but this seems relative
to the bug #6823 in the QCC.
Here is the script of André:
-----------------
-- LE SCRIPT DE DRAG DROP ENTRE 2 FIELDS d'Éric CHATONET, MODIFIÉ POUR UN SEUL
local lLineNo,tLaLigne,tStyle, -- script local variable
----------------------------------
on mouseEnter
set the dragDelta to 5 -- AU LIEU DE 10 : EMPÊCHE UN PEU ERREUR
-- QUI OCNSISTE À PRENDRE UNE AUTRE LIGNE
end mouseEnter
----------------------------------
on dragMove -- sent repeatedly when the dragdata is within the field
local tContents,tHilitedText
-----
put (the mouseV - the top of the target) div the effective
textHeight of the target into lLineNo -- line number
if lLineNo > the number of lines of the target then put the number
of lines of the target into lLineNo
-----
lock screen
put StripCR(me) into tContents -- see below
put the hilitedText of the target into tHilitedText -- stores highlighted line
put cr after line lLineNo of tContents -- creates a blank line
set the text of the target to tContents
set the hilitedLine of the target to
lineOffset(tHilitedText,tContents) -- restores highlighted line
unlock screen
delete line (the hilitedLine of the target) of the target --C'EST RÉPÉTÉ !!!
end dragMove
----------------------------------
on DragLeave -- restores current contents
local tHilitedLine,
-----------
lock screen
put the hilitedLine of the target into tHilitedLine
put StripCR(me) into the target --
set the hilitedLine of the target to tHilitedLine
unlock screen
end DragLeave
----------------------------------
on dragEnter -- NÉCESSAIRE DANS LE CONTROL DE DESTINATION
set the dragAction to "Move"
end dragEnter
----------------------------------
on dragDrop
local tContents
-----
put StripCR(me) into tContents -- see below
if lLineNo = 0 then
put the dragdata["text"] & cr before tContents
else
put cr & the dragdata["text"] after line lLineNo of tContents
end if
lock screen
set the text of the target to tContents
set the hilitedLine of the target to lLineNo + 1 -- sets highlighted
line to dropped line
unlock screen
end dragDrop
----------------------------------
function StripCR pText -- returns 'normal' field's contents
if char 1 of pText = cr then delete char 1 of pText
if char -1 of pText = cr then delete char -1 of pText
replace cr & cr with cr in pText
return pText
end StripCR
-- ---------------------------------
on dragStart --NÉCESSAIRE DANS LE CONTROL SOURCE
--- put the textStyle of the selectedLine into tStyle --MMMMMMMMMMMMMMMM
set the dragData["text"] to the selectedText --to tLaLigne --the
selectedText -- plain text
put the selectedText of the target into fld "Temp" -- in order to
create the right image
-- put tLaLigne into fld "Temp"
set the dragImage to CreateDragImage() -- see below
set the dragImageOffset to the width of last image div 2,the height
of last image div 2 -- centered
end dragStart
---------------------------------
-- set the dragData["html"] to the HTMLText of fld "telField"
---------------------------------
on dragEnd
delete last image -- we no longer need the drag image
end dragEnd
---------------------------------
function CreateDragImage -- creates drag image on-the-fly
local tRect,tempImage
-----
put the rect of fld "Temp" into tRect
-----
export snapshot from rect tRect of this cd to tempImage as jpeg
-- export image to a variable
lock messages -- important to speed up the process
create invisible image -- we don't want to see it
set the text of last image to tempImage
if there is an image ID 6001 then delete image ID 6001
set the ID of last image to 6001
-- setting dimensions
unlock messages
return the ID of last image -- we need it to set the dragImage property
end CreateDragImage
---------------------------------------------
--
-Zryip TheSlug- wish you the best! 8)
http://www.aslugontheroad.co.cc
More information about the use-livecode
mailing list