Page 1 of 1
Is it possible to send a click (mouseUp) to a particular word in a field?
Posted: Sat Apr 03, 2021 9:24 pm
by Fermin
Is it possible to send a click (mouseUp) to a particular word in a field or, alternatively, to a particular line in that field?
For example, let's say I have a field called 'Beatles' with four lines with one word on each line:
GEORGE
RINGO
JOHN
PAUL
and in its script:
Code: Select all
on mouseup
put value (the clickline) into theName
if theName is george then answer theName && "HARRISON"
else
if theName is john then answer theName && "LENNON"
else
if theName is paul then answer theName && "McCARTNEY"
else
if theName is ringo then answer theName && "STARR"
end if
end if
end if
end mouseup
--
I guess the logical thing to do would be to include handlers like 'on ringo' to be triggered by 'send ringo to fld Bealtes'.
But I would like something like:
Code: Select all
send mouseup to word "Ringo" in fld "beatles".
but of course, I don't think that's possible
In summary, I would like to know if there is a way to 'direct' a mouseup to a word or a specific line.
Thank you very much.
Re: Is it possible to send a click (mouseUp) to a particular word in a field?
Posted: Sat Apr 03, 2021 9:32 pm
by dunbarx
Hi.
Is it that you want to be able to select the line that contains a particular word? There is no reason to click on that line, though it would be just another exercise to do so. But why not, given your Beatles are in a field 1 and a button somewhere, this in the button script
Code: Select all
on mouseUp
select line lineOffset("Ringo",fld 1) of fld 1
end mouseUp
Or if you want the word only:
Code: Select all
on mouseUp
select word wordoffset("Ringo",fld 1) of fld 1
end mouseUp
The reason for my question above is that you cannot send a message to a word in a field. Only objects can receive such things.
Craig
Re: Is it possible to send a click (mouseUp) to a particular word in a field?
Posted: Sat Apr 03, 2021 10:18 pm
by Fermin
Thanks, Craig, I know that method and it is very useful to know the position of a line (or a word) in a field, for example to use something like:
but that doesn't work... and what I want to know is how to send,
from another process, a click to the field so that the field script knows which line has been clicked on.
Or in short: Is there a way to code a click on a specific line in a field?

Re: Is it possible to send a click (mouseUp) to a particular word in a field?
Posted: Sat Apr 03, 2021 10:25 pm
by andresdt
Well the answer to your question is yes.
Code: Select all
on mouseUp
select line 1 of fld 1
click button 1 at the selectedLoc
end mouseUp
Now I ask you if it is not easier for you to create a custom manipulator. Let it be the one that is called when it is clicked on the field and you can call it from anywhere else by passing the line number you want to select as a parameter.
Field code
Code: Select all
on mouseUp
selectBeatlesMember the hilitedLine of me
end mouseUp
Code on the card
Code: Select all
command selectBeatlesMember pNum
if pNum is not an integer then exit selectBeatlesMember
if the hilitedLine of field "Beatles" is not pNum
then set the hilitedLine of field "Beatles" to pNum
put the text of line pNum of field "Beatles" into tBeatles
answer tBeatles
end selectBeatlesMember
Code on the button N
Code: Select all
on mouseUp
// I set it to be random for any member of the Beatles to return to me. In your case you must put the number of the line.
selectBeatlesMember random(4)
end mouseUp
Re: Is it possible to send a click (mouseUp) to a particular word in a field?
Posted: Sat Apr 03, 2021 10:42 pm
by Fermin
Yes!!! The selectedloc is what I needed.
Code: Select all
put "Paul" into tWord
put lineoffset (tWord,fld beatles) into tLine
select line tline of control beatles
click at the selectedloc
It works perfectly.
Thank you very much...
Re: Is it possible to send a click (mouseUp) to a particular word in a field?
Posted: Sat Apr 03, 2021 11:27 pm
by Fermin
As usual, there are many different ways to get to the same result. LiveCode has buttons with menus and other types of controllers that would probably work for me, but I tend to use fields with the titles of actions written on their lines that act as triggers or items in a classic menu. It's a bit primitive but I'm familiar with it from the distant days of Hypercard... or was it Supercard?

Normally I usually click 'manually' on the desired title (the line) but lately I needed to trigger it from another process and for that SelectedLoc is great.
I also think that there is a way to know the absolute position (referred to the screen) of a line of a field and that would also have been useful but, without a doubt, the selectedloc is perfect.
Thank you very much, Andresdt
Translated with
www.DeepL.com/Translator (free version)