The selectedtext between 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
GregWills
Posts: 69
Joined: Sun Aug 30, 2015 7:51 am

The selectedtext between fields

Post by GregWills » Mon Sep 21, 2015 3:16 am

Hi Everyone

I am having trouble understanding what is happening here.

I have one field (myChoice) where a line of text is selected by clicking. The line of text is selected using - put the selectedtext into field “WhichPicture” (List Behaviour of field “MyChoice” is; Click to toggle, Multi-line and Non-Contiguous selected).

The line of text are placed into another field (WhichPicture).

This works fine and multiple lines can be selected and de-selected in field “myChoice”.

When I click on a line of text in the field “WhichPicture" (which now has lines of text) to show a related image, this also works as expected - appropriate images can be shown. (Field “WhichPicture" has List Behaviour of ‘Click to toggle” only)

If I then go to the field (myChoice) and select an additional line of text, then an additional line of text appears in field (WhichPicture) - which is what is wanted.

However.
Once I have clicked on a line of text in field “WhichPicture", when I click on a line of text in field “myChoice” that is already selected, i.e., to deselect a line of text, then ALL of the field “WhichPicture” is cleared. This doesn’t occur if I select an additional line in field “myChoice”.

Any suggestions? Thanks in advance.

regards

Greg

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

Re: The selectedtext between fields

Post by dunbarx » Mon Sep 21, 2015 4:36 am

Hi,

What is the code you are using to move the text to the other field?

Craig Newman

GregWills
Posts: 69
Joined: Sun Aug 30, 2015 7:51 am

Re: The selectedtext between fields

Post by GregWills » Mon Sep 21, 2015 11:15 pm

Thanks Craig

I’ve striped all the code in field “myChoice" down to just

on mouseup
put the selectedtext into field "WhichPicture"
end mouseup

With no script in field “WhichPicture”, when I click on a line in field “WhichPicture”, then return to field “myChoice” and click on a highlighted line, all of the text in field “WhichPicture” is cleared. If I then click on another line of text in field “myChoice” that is not highlighted, then all of the lines are returned to field “WhichPicture”.

It seems like the ‘selectedtext’ in the first field is ‘lost’ when the second field lines are clicked.

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

Re: The selectedtext between fields

Post by dunbarx » Mon Sep 21, 2015 11:37 pm

Hi again.

Where is the handler located?

Craig

GregWills
Posts: 69
Joined: Sun Aug 30, 2015 7:51 am

Re: The selectedtext between fields

Post by GregWills » Tue Sep 22, 2015 12:18 am

Hi

In the field “myChoice"

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

Re: The selectedtext between fields

Post by dunbarx » Tue Sep 22, 2015 2:39 am

Ah.

If you click on a line in a list field that is already selected, that line is deselected. And consequently the selectedText is empty, and that emptiness in loaded into your field "whichPicture". The selectedText is evaluated after the selection, and in kind, the deselection. This falls into the details of how LC really works, down only slightly deep, but deeper than the user normally needs to worry about. Good stuff...

So you have to fix this. Do you see how to?

Write back if you need a clue.

Craig

GregWills
Posts: 69
Joined: Sun Aug 30, 2015 7:51 am

Re: The selectedtext between fields

Post by GregWills » Tue Sep 22, 2015 3:05 am

Ha, thanks Craig. I'll contemplate the problem while you sleep :)

cheers

Greg

golive
Posts: 98
Joined: Wed Jul 01, 2015 5:16 am

Re: The selectedtext between fields

Post by golive » Tue Sep 22, 2015 3:42 am

GregWills wrote:Hi

In the field “myChoice"
Just a guess: after instead of into ?

on mouseup
put the selectedtext after field "WhichPicture"
end mouseup

GregWills
Posts: 69
Joined: Sun Aug 30, 2015 7:51 am

Re: The selectedtext between fields

Post by GregWills » Tue Sep 22, 2015 3:51 am

Craig, thanks for your explanation and prompt for me to explore it again. I'm not sure what you had in mind, but this worked;

on mouseup
put the selection of me into field "myChoice"
end mouseup

That's all it took. So 'the selectedtext' was too specific and captured only the empty selection.

Great. Thanks again. Hope I didn't wake you!!!

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

Re: The selectedtext between fields

Post by dunbarx » Tue Sep 22, 2015 2:07 pm

Hi.

My thought was something along the lines of:

Code: Select all

on mouseup
   if the selectedText <> "" then put the selectedtext into field "WhichPicture"
   else put the value of the clickLine into fld "whichPicture"
end mouseup
The value of the clickLine is independent of the selectedText. And you will get nothing if you click on a blank line. But whatever works, eh?
on mouseup
put the selection of me into field "myChoice"
end mouseup
Know that you do not need "of me", as the selection has a life of its own.

Craig

GregWills
Posts: 69
Joined: Sun Aug 30, 2015 7:51 am

Re: The selectedtext between fields

Post by GregWills » Wed Sep 23, 2015 3:56 am

Thanks Craig

Interestingly, I tried removing the 'of me'; i.e. put the selection into field "myChoice"

and it didn't work. So I have kept; put the selection of me into field "myChoice"

I think that is where I originally started using the selectedtext when "put the selection" didn't do as I wanted.

Great discussion points. Thanks.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”