Text as dragImage

Richard Gaskin ambassador at fourthworld.com
Tue Mar 15 10:43:24 EDT 2011


Devin Asay wrote:

 > I had mistakenly assumed that if a field was hidden a snapshot of
 > the field would not show that field, but what was behind it. The
 > dictionary entry for import snapshot is not as clear as is could
 > be, but with a little trial and error I came up with this:
 >
 > on dragStart
 >     set the allowableDragActions to "copy"
 >     set the dragAction to "copy"
 >     set the dragData["private"] to word 2 of the clickLIne
 >     put the clicktext into tText
 >     put tText into fld "dragFld"
 >     set the width of fld "dragFld" to the formattedWidth of fld
 > "dragFld"
 >     lock screen
 >     import snapshot from (the long id of fld "dragFld" of this cd)
 >     set the name of last image of this card to "dragImg"
 >     hide img "dragImg"
 >     unlock screen
 >     set the dragImage to the id of img "dragImg"
 > end dragStart

With the rendering enhancements in v2.7 the engine now supports 
exporting any object to a snapshop - even ones that aren't on the 
current card, things that are offscreen, hidden objects, etc.   With the 
"from <object>" form as you're using the engine renders the object into 
the buffer from scratch rather than grab its rect from the current 
window buffer, which makes your use and a great many others possible 
(even easy <g>).

BUT -

Unfortunately the dragImage property is not yet supported on Linux:
<http://quality.runrev.com/qacenter/show_bug.cgi?id=9386>

So if you need a truly cross-platform solution you'll have to do what 
RunRev did when they first wrote their IDE (which predates the dragImage 
property):  put your image into a new temporary translucent stack, 
tracking the mouse to move it and doing your own hit-testing to monitor 
when you should show your drop hilite.

Ugly, but until we get dragImage for Linux I know of no other way....

--
  Richard Gaskin
  Fourth World
  LiveCode training and consulting: http://www.fourthworld.com
  Webzine for LiveCode developers: http://www.LiveCodeJournal.com
  LiveCode Journal blog: http://LiveCodejournal.com/blog.irv




More information about the use-livecode mailing list