Drag 'n' drop in text fields

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Drag 'n' drop in text fields

Post by richmond62 » Mon Oct 28, 2019 10:18 pm

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
Attachments
Ru Paul.livecode.zip
Here's the stack.
(1.04 KiB) Downloaded 187 times

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Drag 'n' drop in text fields

Post by Klaus » Mon Oct 28, 2019 10:26 pm

Erm... no! 8)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Drag 'n' drop in text fields

Post by richmond62 » Mon Oct 28, 2019 10:38 pm

-
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
Attachments
Ru Paul 2.livecode.zip
Here's the stack.
(995 Bytes) Downloaded 189 times

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Drag 'n' drop in text fields

Post by Klaus » Mon Oct 28, 2019 10:45 pm

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)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Drag 'n' drop in text fields

Post by richmond62 » Mon Oct 28, 2019 10:47 pm

Wow! 8)

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

Post Reply