Page 1 of 1

Drag 'n' drop in text fields

Posted: Mon Oct 28, 2019 10:18 pm
by richmond62
klaus posted elsewhere:

"Hi all,

quick question LC 9.5 on macOS 10.14.6:

We can drag'n'drop text into textfields and
this works without any scripting.

We can also drag'n'drop one or more files into
a textfield and the filepath appears in the field
where we dropped the file(s).

However there does not seem to be any message
send to the field when dropping a file, but I want
to catch it."

Here's a thought:

(code of the target field)

Code: Select all

local fldState

on mouseEnter
   if fld "fff" is empty then put "0" into fldState
end mouseEnter

on mouseWithin
   if fld "fff" is empty then
      -- do nothing
   else
      put "1" into fldState
   end if
   if fldState > 0 then
      set the textColor of fld "fff" to red
   end if
end mouseWithin

Re: Drag 'n' drop in text fields

Posted: Mon Oct 28, 2019 10:26 pm
by Klaus
Erm... no! 8)

Re: Drag 'n' drop in text fields

Posted: Mon Oct 28, 2019 10:38 pm
by richmond62
-
pathname is in the field.
-
This is also fun:

Code: Select all

on mouseWithin
   put the selectedText of me
end mouseWithin
-
Screenshot 2019-10-28 at 23.37.32.png

Re: Drag 'n' drop in text fields

Posted: Mon Oct 28, 2019 10:45 pm
by Klaus
TEXTCHANGED was the magic word!

This does what I want:

Code: Select all

on textChanged
 send "doit" to me in 10
end textChanged

command doit
 put the selectedtext of me
end doit
Please read up my problem again, your solutions are ideal for a problem that I do not have. 8)

Re: Drag 'n' drop in text fields

Posted: Mon Oct 28, 2019 10:47 pm
by richmond62
Wow! 8)

Your message contains 8 characters.
You need to enter at least 10 characters.