text in field + other question

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
docHerman
Posts: 29
Joined: Sat Mar 24, 2012 9:20 pm

text in field + other question

Post by docHerman » Wed Apr 11, 2012 9:18 pm

dear all

another question:
I try to make it easy finding adresses. So when you select Groningen, you find adresses from people in Groningen.
I made a field groningentxt (containing the adresses) and put it invisible on the card

so I wrote:

Code: Select all

on mouseup
   put "empty" into field "adressenveld"
   if "groningen" is in the clicktext then put groningentxt into field "adressenveld"
end mouseup
hoping the contents of the groningentxt would be put in the adressen-field. Unfortunate, it didn't.
Can someone help me again?

Other question: when the adress is shown, how can email or telephonenumber be selected and activated?

Waiting for your kind responses,

docH
Attachments
Schermafbeelding 2012-04-11 om 22.14.13.png
Schermafbeelding 2012-04-11 om 22.14.13.png (13.26 KiB) Viewed 8582 times

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: text in field + other question

Post by jmburnod » Wed Apr 11, 2012 9:55 pm

Hi DocH,

You must declare groningentxt is a fld
I think this script help you

Code: Select all

on mouseup
   put "empty" into field "adressenveld"
   --if "groningen" is in the clicktext then put field "groningentxt" into field "adressenveld" -- Your line
   if "groningen" is in the clicktext then put field "groningentxt" into field "adressenveld" 
end mouseup
Best regards

Jean-Marc
https://alternatic.ch

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: text in field + other question

Post by dunbarx » Wed Apr 11, 2012 10:17 pm

As Jeam-Marc said, be careful about your references. As you originally wrote it, "groninText" is seen as a variable, not a field.

As for your other question, how do you want to view the data? There are more complex objects like datagrids and table fields that can display multiple lines of separate data, much like a spreadsheet. These take a little practice to learn. Since you are new with LiveCode, it would probably be better to place your email and phone information directly in the field. This is more for your own learning than for beauty or utility. Anyway, when anyone clicks on the text of either an e-mail or a phone number, that data can be processed:

name1 phone1 email1
name2 phone2 email2
name3 phone3 email3

You would use the "clickText" function to get the data using a "mouseUp" handler. You have to lock the text of the field. You must set the textStyle of these pieces of data to "link", so that the whole of the value will be returned. Try this without setting it that way. Can you do this?

Craig Newman

docHerman
Posts: 29
Joined: Sat Mar 24, 2012 9:20 pm

Re: text in field + other question

Post by docHerman » Thu Apr 12, 2012 9:37 pm

@Jean-Marc: it works, thanx!
@Craig: I succeed, however now the whole text is linked (blue and underlined); I would like that oly the emailaddress and phone-numbers are linked and activated when clicked.

eg:

Jan Janssen
phone: +316123456
email: info@janssen.nl
profession: dirctor

Hope to hear soon again,
greeting docH

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: text in field + other question

Post by dunbarx » Fri Apr 13, 2012 12:39 am

You can select only those pieces of data when you set the style to linked. Set each email and phone number to "link" separately. It would be a good exercise to write a script to do this for you.

You can lose the underline by invoking "hide groups" in the message box. I am not quite sure how to get rid of the blue color.

Maybe there is another way to do this. I will think about it, and meanwhile I bet someone else will come up with a solution.

Craig Newman

docHerman
Posts: 29
Joined: Sat Mar 24, 2012 9:20 pm

Re: text in field + other question

Post by docHerman » Mon Apr 16, 2012 9:23 pm

@Craig
Set each email and phone number to "link" separately.
How do I do this? When I open the Card Ispector, I can select an emailaddress in Contents. However, when I go to Text Formatting and select the Style Linked Text, all lines-and-words are selected [not just the email address].

Then, when the text is linked, how can I make it mail or phone?

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: text in field + other question

Post by jmburnod » Mon Apr 16, 2012 9:55 pm

Hi Jan,

I think you have a list with e-mail and other texts
You can use a script to set the Textstyle of a chunk to "link".
Then you can set the Textstyle of each word it contains "@" :D

One or more discovers each day

Best regards

Jean-Marc
https://alternatic.ch

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: text in field + other question

Post by dunbarx » Mon Apr 16, 2012 10:30 pm

What Jean-Marc is saying is that you can write something like:

set word 2 of line 2 of field "yourDataField" to "link"

or

set item 2 of line 2 of field "yourDataField" to "link"

This requires that your data be separated (delimited, in the vernacular) in some predictable way, by word or items, as above.

Do you see how to do this? Far more importantly, do you see a way to write a script to do this tedious task?

Write back, as always.

Craig Newman

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: text in field + other question

Post by mwieder » Mon Apr 16, 2012 10:48 pm

...and what Craig is trying to say is

Code: Select all

set the textStyle of word 2 of line 2 of field "yourDataField" to "link"
or

Code: Select all

set the textStyle of item 2 of line 2 of field "yourDataField" to "link"

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: text in field + other question

Post by jmburnod » Mon Apr 16, 2012 10:59 pm

Hi jan,

Try this

Code: Select all

on mouseUp
  put the num of words of fld "myField" into nbw
   set the cursor to busy
   repeat with i = 1 to nbw
   if the optionkey is down then exit repeat
      if "@" is in word i of fld "myField"  then
         set the textstyle of word i of fld "myField"  to "link"
         wait 1 milliseconds
      end if
   end repeat
end mouseUp
Best regards

Jean-Marc
https://alternatic.ch

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: text in field + other question

Post by mwieder » Mon Apr 16, 2012 11:19 pm

I'd also add one more line:

Code: Select all

      if "@" is in word i of fld "myField"  then
         set the textstyle of word i of fld "myField"  to "link"
         -- do something when we click the link
         set the linktext of word i of field "myField" to ("mailto:" & word i of field "myField")
         wait 1 milliseconds
      end if

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: text in field + other question

Post by dunbarx » Mon Apr 16, 2012 11:29 pm

Did I really write: set word 2 of line 2 of field "yourDataField" to "link"

Shows the dangers of writing these things while driving to work.

Craig

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: text in field + other question

Post by mwieder » Mon Apr 16, 2012 11:38 pm

LOL <cleans coffee from keyboard...>

docHerman
Posts: 29
Joined: Sat Mar 24, 2012 9:20 pm

Re: + other questions

Post by docHerman » Thu Apr 19, 2012 11:16 pm

Hijean-Marc and Craig

I tried the following:

Code: Select all

on mouseUp
 put the num of words of fld "Fieldcontact" into nbw
 set the cursor to busy
 repeat with i = 1 to nbw
 if the optionkey is down then exit repeat
if "@" is in word i of fld "Fieldcontact" then
   set the textstyle of word i of fld "Fieldcontact" to "link"
   wait 1 seconds
    -- do something when we click the link
    revmail  "kinderneurologie@xs4all.nl",,"contact met betrekking tot de App anamnese"
    wait 1 milliseconds
    set the textstyle of word i of fld "Fieldcontact" to "plain"
   end if
 end repeat
end mouseUp
When I hit the field 'Fieldcontact', the emailadress is underlined perfectly and an email is made. However, it doesn't matter which part of the field is clicked, an email is made whatsoever.
How can i change it so email is made only hen I click the emailaddress?

By the way, my first App (1st vesion of this one) is already accepted in the App store :D ; it's called: anamnese.

docH

docHerman
Posts: 29
Joined: Sat Mar 24, 2012 9:20 pm

Re: text in field + other question

Post by docHerman » Thu Apr 19, 2012 11:18 pm

Hi Marc

I forgot to say hello to you. Sorry for that :oops:
sorry in advance if I forgot anybody else.... :mrgreen:

docH

Post Reply