Re: Drag and Drop in a locked field

2012-02-10 Thread André Bisseret
Bonjour Bob,

In some apps I am using the following script.
It is an adaptation to drap and drop inside one field, of a script from Eric 
Chatonet he had written for drag and drop from one field to another.

Besides the field, this script uses an extra field name tempo which allows to 
see what line one is dragging.

A bug (# 6823) prevented this script to work well in a grouped field (but the 
Slug had writte a workaround).

Seems that now this bug has been fixed : I just tried the script on a grouped 
field and it works.

Best regards from Grenoble

André



--- THE SCRIPT OF THE FIELD ---

local lLineNo,tLaLigne,tStyle, -- script local variable
--
on mouseEnter
set the dragDelta to 5 -- instead of 10 seems to prevent to drag a wrong 
line too often
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
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
set the dragData[text] to the selectedText
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

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



Le 10 févr. 2012 à 01:35, Bob Sneidar a écrit :

 Hi all. I use locked fields with multiple lines and listBehavior set to true 
 as a kind of menu. Now I am trying to allow the user to rearrange the items 
 in the list. I read in the Dictionary that LC handles drag and drop between 
 *unlocked* fields automatically. Crud. So I tried unlocking the field on 
 mouseDown and then sending mouseDown again in 0 seconds, but that was a bust. 
 I tried just unlocking the field on mouseDown and locking it on mouseUp but 
 that was problematic too. 
 
 Any easy way to implement this? I could use a datagrid I suppose (grumble 
 grumble) but it would be nice if I could just do this with a simple list 
 field. I want to reorder entire lines by dragging and dropping them. 
 
 Bob
 ___
 use-livecode mailing list
 

Re: Drag and Drop in a locked field

2012-02-10 Thread Peter M. Brigham, MD
On Feb 9, 2012, at 7:50 PM, Ken Ray wrote:

 On Feb 9, 2012, at 6:35 PM, Bob Sneidar wrote:
 
 Hi all. I use locked fields with multiple lines and listBehavior set to true 
 as a kind of menu. Now I am trying to allow the user to rearrange the items 
 in the list. I read in the Dictionary that LC handles drag and drop between 
 *unlocked* fields automatically. Crud. So I tried unlocking the field on 
 mouseDown and then sending mouseDown again in 0 seconds, but that was a 
 bust. I tried just unlocking the field on mouseDown and locking it on 
 mouseUp but that was problematic too. 
 
 Any easy way to implement this? I could use a datagrid I suppose (grumble 
 grumble) but it would be nice if I could just do this with a simple list 
 field. I want to reorder entire lines by dragging and dropping them. 
 
 I'm using a variation of Scott Rossi's Get In Line implementation… you can 
 download the stack directly with this URL:
 
   http://www.tactilemedia.com/site_files/downloads/getinline.rev.zip
 
 Scott's got a lot of great tutorials and demos at his site, so you should 
 check out:
 
   http://www.tactilemedia.com/site_files/software/tutorials.html

I use Scott's getinline handlers and I love them. They work like a charm.

-- Peter

Peter M. Brigham
pmb...@gmail.com
http://home.comcast.net/~pmbrig


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Drag and Drop in a locked field

2012-02-10 Thread Bob Sneidar
Thanks I already went with GetInLine and I like the way it looks. Scott's stuff 
is always visually pleasing. Paypal donation on the way!

Bob


On Feb 10, 2012, at 1:13 AM, André Bisseret wrote:

 Bonjour Bob,
 
 In some apps I am using the following script.
 It is an adaptation to drap and drop inside one field, of a script from Eric 
 Chatonet he had written for drag and drop from one field to another.
 
 Besides the field, this script uses an extra field name tempo which allows 
 to see what line one is dragging.
 
 A bug (# 6823) prevented this script to work well in a grouped field (but the 
 Slug had writte a workaround).
 
 Seems that now this bug has been fixed : I just tried the script on a grouped 
 field and it works.
 
 Best regards from Grenoble
 
 André
 
 
 
 --- THE SCRIPT OF THE FIELD ---
 
 local lLineNo,tLaLigne,tStyle, -- script local variable
 --
 on mouseEnter
set the dragDelta to 5 -- instead of 10 seems to prevent to drag a wrong 
 line too often
 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
 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
set the dragData[text] to the selectedText
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
 
 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
 
 
 
 Le 10 févr. 2012 à 01:35, Bob Sneidar a écrit :
 
 Hi all. I use locked fields with multiple lines and listBehavior set to true 
 as a kind of menu. Now I am trying to allow the user to rearrange the items 
 in the list. I read in the Dictionary that LC handles drag and drop between 
 *unlocked* fields automatically. Crud. So I tried unlocking the field on 
 mouseDown and then sending mouseDown again in 0 seconds, but that was a 
 bust. I tried just unlocking the field on mouseDown and locking it on 
 mouseUp but that was problematic too. 
 
 Any easy way to implement this? I could use a datagrid I 

Re: Drag and Drop in a locked field

2012-02-10 Thread Mark Smith

slylabs13 wrote
 
 Any easy way to implement this? I could use a datagrid I suppose (grumble
 grumble) but it would be nice if I could just do this with a simple list
 field. I want to reorder entire lines by dragging and dropping them. 
 

Hi Bob, I wrote something to do that awhile back and added the ability
(through a pop-over menu) to add, edit and delete items from the list, and
sort the list up/down. However, bug 7766 prevented the drag drop from
working on x86 and I don't think that problem has been resolved. Just tried
posting the stack (the list is implemented as a group: a scrolling list,
pop-over menu and hidden field so grouping it made it easy to just drag drop
the whole shebang onto a card) into rev online but it stopped responding so
mail me offline if you want me to send you a copy. I'll post it to rev
online once its back up (Enhanced Scrolling List).

-- Mark


--
View this message in context: 
http://runtime-revolution.278305.n4.nabble.com/Drag-and-Drop-in-a-locked-field-tp4374946p4377388.html
Sent from the Revolution - User mailing list archive at Nabble.com.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Drag and Drop in a locked field

2012-02-10 Thread Mark Smith
Sorry, its been awhile since I worked on it and so I should clarify: the 7766
bug only rears its head after using the pop-up menu. If you disable the
pop-up menu option the drag drop works fine on x86.

-- Mark

--
View this message in context: 
http://runtime-revolution.278305.n4.nabble.com/Drag-and-Drop-in-a-locked-field-tp4374946p4377399.html
Sent from the Revolution - User mailing list archive at Nabble.com.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Drag and Drop in a locked field

2012-02-10 Thread Bob Sneidar
Thanks Mark! Bunch of friendlier people I have never known! :-) So far I am 
using Scott's Getinline solution. I like his little drag insert graphic! 

Bob


On Feb 10, 2012, at 12:01 PM, Mark Smith wrote:

 
 slylabs13 wrote
 
 Any easy way to implement this? I could use a datagrid I suppose (grumble
 grumble) but it would be nice if I could just do this with a simple list
 field. I want to reorder entire lines by dragging and dropping them. 
 
 
 Hi Bob, I wrote something to do that awhile back and added the ability
 (through a pop-over menu) to add, edit and delete items from the list, and
 sort the list up/down. However, bug 7766 prevented the drag drop from
 working on x86 and I don't think that problem has been resolved. Just tried
 posting the stack (the list is implemented as a group: a scrolling list,
 pop-over menu and hidden field so grouping it made it easy to just drag drop
 the whole shebang onto a card) into rev online but it stopped responding so
 mail me offline if you want me to send you a copy. I'll post it to rev
 online once its back up (Enhanced Scrolling List).
 
 -- Mark
 
 
 --
 View this message in context: 
 http://runtime-revolution.278305.n4.nabble.com/Drag-and-Drop-in-a-locked-field-tp4374946p4377388.html
 Sent from the Revolution - User mailing list archive at Nabble.com.
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Drag and Drop in a locked field

2012-02-09 Thread Ken Ray

On Feb 9, 2012, at 6:35 PM, Bob Sneidar wrote:

 Hi all. I use locked fields with multiple lines and listBehavior set to true 
 as a kind of menu. Now I am trying to allow the user to rearrange the items 
 in the list. I read in the Dictionary that LC handles drag and drop between 
 *unlocked* fields automatically. Crud. So I tried unlocking the field on 
 mouseDown and then sending mouseDown again in 0 seconds, but that was a bust. 
 I tried just unlocking the field on mouseDown and locking it on mouseUp but 
 that was problematic too. 
 
 Any easy way to implement this? I could use a datagrid I suppose (grumble 
 grumble) but it would be nice if I could just do this with a simple list 
 field. I want to reorder entire lines by dragging and dropping them. 

I'm using a variation of Scott Rossi's Get In Line implementation… you can 
download the stack directly with this URL:

   http://www.tactilemedia.com/site_files/downloads/getinline.rev.zip

Scott's got a lot of great tutorials and demos at his site, so you should check 
out:

   http://www.tactilemedia.com/site_files/software/tutorials.html

Ken Ray
Sons of Thunder Software, Inc.
Email: k...@sonsothunder.com
Web Site: http://www.sonsothunder.com/  

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Drag and Drop in a locked field

2012-02-09 Thread Bob Sneidar
Thanks I will give it a go. I have it partially working, but I found if I drag 
too fast the engine selects another line before dragStart is triggered. Also I 
had to send dragEnter from the dragStart handler otherwise the process never 
kicked off. I tried sending dragStart in a mouseDown handler, but that didn't 
seem to fix it. Weird. This sort of thing should be automatic in the engine 
IMHO. Seems like a common thing to want to rearrange lines in a list by 
dragging and dropping. 

Bob


On Feb 9, 2012, at 4:50 PM, Ken Ray wrote:

 
 On Feb 9, 2012, at 6:35 PM, Bob Sneidar wrote:
 
 Hi all. I use locked fields with multiple lines and listBehavior set to true 
 as a kind of menu. Now I am trying to allow the user to rearrange the items 
 in the list. I read in the Dictionary that LC handles drag and drop between 
 *unlocked* fields automatically. Crud. So I tried unlocking the field on 
 mouseDown and then sending mouseDown again in 0 seconds, but that was a 
 bust. I tried just unlocking the field on mouseDown and locking it on 
 mouseUp but that was problematic too. 
 
 Any easy way to implement this? I could use a datagrid I suppose (grumble 
 grumble) but it would be nice if I could just do this with a simple list 
 field. I want to reorder entire lines by dragging and dropping them. 
 
 I'm using a variation of Scott Rossi's Get In Line implementation… you can 
 download the stack directly with this URL:
 
   http://www.tactilemedia.com/site_files/downloads/getinline.rev.zip
 
 Scott's got a lot of great tutorials and demos at his site, so you should 
 check out:
 
   http://www.tactilemedia.com/site_files/software/tutorials.html
 
 Ken Ray
 Sons of Thunder Software, Inc.
 Email: k...@sonsothunder.com
 Web Site: http://www.sonsothunder.com/
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode