Error on 'put "My text" into the selection'

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

mrcoollion
Posts: 421
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Error on 'put "My text" into the selection'

Post by mrcoollion » Wed Jun 19, 2019 10:43 am

Hello fellow LiveCoders

I so not understand why I get the below error in a one line script. I cannot be any simpler..
Error message is:
Button "InsertSource": execution error at line 2 (Chunk: no target found), char 1
The script in the button is :

Code: Select all

on mouseUp
   put "Text to insert at cursor" into the selection
end mouseUp
Working with LC 9.5 (dp 1) on Windows 10

Regards,

Paul (mrcoollion)
Last edited by mrcoollion on Fri Jun 21, 2019 9:01 am, edited 2 times in total.

Klaus
Posts: 11332
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Error on 'put "My text" into the selection'

Post by Klaus » Wed Jun 19, 2019 11:26 am

Hi Paul,

works as exspected in LC 9.04 on macOS 10.14.5.
Maybe a bug in DP1?


Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6266
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Error on 'put "My text" into the selection'

Post by dunbarx » Wed Jun 19, 2019 3:54 pm

Hi.

Works for me too, on a Mac. This must be an odd regression.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7040
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Error on 'put "My text" into the selection'

Post by FourthWorld » Wed Jun 19, 2019 7:05 pm

Is that script in a button, and is the button's traversalOn property set to true?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6266
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Error on 'put "My text" into the selection'

Post by dunbarx » Wed Jun 19, 2019 11:36 pm

Richard.

I assumed the text was in a field.

Paul?

Craig

Klaus
Posts: 11332
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Error on 'put "My text" into the selection'

Post by Klaus » Wed Jun 19, 2019 11:45 pm

dunbarx wrote:
Wed Jun 19, 2019 11:36 pm
I assumed the text was in a field.
Only a locked field will receive mouseup (1) messages! An unlocked field will only receive a right-click = mouseup (2) message, where the number is the number of the clicked mouse-button.

And if a button has it traversalon property set to true, it will get the focus when clicked and thus remove an eventual text selection.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7040
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Error on 'put "My text" into the selection'

Post by FourthWorld » Wed Jun 19, 2019 11:46 pm

dunbarx wrote:
Wed Jun 19, 2019 11:36 pm
Richard.

I assumed the text was in a field.
Yes, so do I. My question was about the button containing the script that acts on that field.

If the traversalOn property of the button is true (which for most button styles is the default), what's reported here makes sense, and is consistent with every version I've used since 1998.

When traversalOn is true, clicking on the button shifts focus away from any previously-selected object to the button. So if text is selected, we would see that selection cleared once the mouse goes down on the button. Once the selection is cleared, "the selection" no longer returns a valid chunk reference, which would give rise to the error shown.

Turning off the traversalOn property of the button should remedy this easily. Provided, that is, that the traversalOn is currently true. To know that we'll have to wait for the OP to reply.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

mrcoollion
Posts: 421
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Error on 'put "My text" into the selection'

Post by mrcoollion » Thu Jun 20, 2019 9:37 am

Hi everyone,

Thanks for the support.
After some testing the traversal property (Focus with keyboard) set to true was the reason it did not worked.
I should have known this myself... :oops: Probably had tooo much ..... in the weekend :lol:

Thanks again...

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7040
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Error on 'put "My text" into the selection'

Post by FourthWorld » Thu Jun 20, 2019 11:37 am

mrcoollion wrote:
Thu Jun 20, 2019 9:37 am
I should have known this myself... :oops: Probably had tooo much ..... in the weekend :lol:
One never needs to apologise for living well. :)
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Klaus
Posts: 11332
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Error on 'put "My text" into the selection'

Post by Klaus » Thu Jun 20, 2019 11:40 am

FourthWorld wrote:
Thu Jun 20, 2019 11:37 am
mrcoollion wrote:
Thu Jun 20, 2019 9:37 am
I should have known this myself... :oops: Probably had tooo much ..... in the weekend :lol:
One never needs to apologise for living well. :)
Exactly!

Exspect our invoices at the end of this month! :)

mrcoollion
Posts: 421
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Error on 'put "My text" into the selection' (Solved)

Post by mrcoollion » Thu Jun 20, 2019 2:03 pm

I only pay in beer :D so you are welcome to visit me in the Netherlands :wink:

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6266
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Error on 'put "My text" into the selection' (Solved)

Post by dunbarx » Thu Jun 20, 2019 2:03 pm

Hmmm.

I have a field and a button. The traversalOn of the button is set to "true". The script of the button is:

Code: Select all

  put "XXX" into the selection
I select a word in the field, and then click on the button. "XXX" appears in place of the selectedText

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7040
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Error on 'put "My text" into the selection' (Solved)

Post by FourthWorld » Thu Jun 20, 2019 4:42 pm

I don't believe I've ever seen that. Can you post that example stack?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6266
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Error on 'put "My text" into the selection' (Solved)

Post by dunbarx » Thu Jun 20, 2019 5:55 pm

Glad the "Solved" appended to this thread did not close it. May I request of the OP that he remove that word?

Paul?

@ Richard.

All I did was create a new stack, adding a button and a field. I put a few words into the field, and this into the button script:

Code: Select all

on mouseUp
     put "XXX" into the selection
end mouseUp
I now select a word in the field, and click the button. Oh, and it matters not the state of traversalOn.

I can certainly post the stack, but there is nothing unusual about it. Are you saying that this does not happen for you?

Craig

Klaus
Posts: 11332
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Error on 'put "My text" into the selection' (Solved)

Post by Klaus » Thu Jun 20, 2019 6:39 pm

Just tested with LC 9.04 on macOS 10.14.5, and yes traversalon or not, it works as advertized.
Looks like they have changed this in a former version, but this did definitively not work a long time ago.

Post Reply

Return to “Talking LiveCode”