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!
I have been adding the facility of links to my project.
The experimental code below works fine in the text field it is attached to when I want to create a link or remove an existing one. In so doing, I have no way to actually click and run the link.
How is this typically done?
on mouseup
select the clickChunk
if the textStyle of the clickChunk = "link" then
set the textStyle of the clickChunk to "plain"
else
set the textStyle of the clickChunk to "link"
set the linkText of the clickChunk to "https://www.livecode.com"
end if
end mouseup
Hi,
I see to ways now:
1. If that is for desktop app you may use option key to open your edit tools.
2. Using the delay between mouseDown and mouseUp to decide what your script does.
Best regards
Jean-Marc
local sDepTime
on mousedown
put the seconds into sDepTime
end mousedown
on mouseup
if the seconds - sDepTime > 3 then
select the clickChunk
if the textStyle of the clickChunk = "link" then
set the textStyle of the clickChunk to "plain"
else
set the textStyle of the clickChunk to "link"
set the linkText of the clickChunk to "https://www.livecode.com"
end if
else
if the textStyle of the clickChunk = "link" then --
get the linkText of the clickChunk
launch url it
end if
end if
end mouseup
Hi, Craig. The act of adding or removing a link by touch or click of it prevents the option of clicking on it to run it. Adding the url code is fine, but how can you click on the link to run it if so doing removes or adds it. That is the problem here.
Quailcreek, this text is not static or predictable so the user needs 3 options.
1. Create a link at the word of choice. A dialogue box would ask for the destination of the new link.
2. To remove a link created by mistake, by the user. Finger trouble...
3. To click the link to do what the link intended.
Obviously, only the first 2 are possible the way I have approached it. It needs to be simple and intuitive, not the pot luck approach of typical social apps i have looked at. All of which have a poor user interface, according to those who pontificate on the subject.
Jmburnod, I think you are on the right lines here. Very imaginative. Your my kinda guy.
I see no actual downside to your idea, because once the link is created and correct, it won't need to change. Brilliant...
The final result of the challenge is in the attached ZIP
I tidied it up and made it so some other newbie can copy and paste the field, button and the scripts into their own project.
It is quite easy to follow I believe and I hope you find it interesting / useful.
on mouseup
put the value of the clickLine into tLink
select the clickChunk
if the textStyle of the clickChunk = "link" then
set the textStyle of the clickChunk to "plain"
else
set the textStyle of the clickChunk to "link"
set the linkText of the clickChunk to "https://www.livecode.com"
end if
launch url tLink
end mouseUp
some words here http://www.liveCode.com some more words here
the "clickText" will not include the "http://" portion? Certainly unless a string of text is "grouped" via having its link property set, LC will not see it as a single "word". And similarly "the value of the clickLine" is perhaps a bit too inclusive?
But is that the sole issue here? If so, it seems that there is a simple way forward.