Page 1 of 1

text in field + other question

Posted: Wed Apr 11, 2012 9:18 pm
by docHerman
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

Re: text in field + other question

Posted: Wed Apr 11, 2012 9:55 pm
by jmburnod
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

Re: text in field + other question

Posted: Wed Apr 11, 2012 10:17 pm
by dunbarx
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

Re: text in field + other question

Posted: Thu Apr 12, 2012 9:37 pm
by docHerman
@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

Re: text in field + other question

Posted: Fri Apr 13, 2012 12:39 am
by dunbarx
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

Re: text in field + other question

Posted: Mon Apr 16, 2012 9:23 pm
by docHerman
@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?

Re: text in field + other question

Posted: Mon Apr 16, 2012 9:55 pm
by jmburnod
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

Re: text in field + other question

Posted: Mon Apr 16, 2012 10:30 pm
by dunbarx
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

Re: text in field + other question

Posted: Mon Apr 16, 2012 10:48 pm
by mwieder
...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"

Re: text in field + other question

Posted: Mon Apr 16, 2012 10:59 pm
by jmburnod
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

Re: text in field + other question

Posted: Mon Apr 16, 2012 11:19 pm
by mwieder
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

Re: text in field + other question

Posted: Mon Apr 16, 2012 11:29 pm
by dunbarx
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

Re: text in field + other question

Posted: Mon Apr 16, 2012 11:38 pm
by mwieder
LOL <cleans coffee from keyboard...>

Re: + other questions

Posted: Thu Apr 19, 2012 11:16 pm
by docHerman
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

Re: text in field + other question

Posted: Thu Apr 19, 2012 11:18 pm
by docHerman
Hi Marc

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

docH