Make Hyperlinks active

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: Klaus, FourthWorld, heatherlaine, kevinmiller

bbhank
Posts: 116
Joined: Thu Mar 17, 2016 6:04 pm

Re: Make Hyperlinks active

Post by bbhank » Mon Apr 11, 2016 10:17 am

Code: Select all

-- This script defines the behavior of your data grid's custom template. This behavior
-- only applies to 'forms' and not 'tables'.

on FillInData pDataArray
   -- This message is sent when the Data Grid needs to populate
   -- this template with the data from a record. pDataArray is an
   -- an array containing the records data.
   -- You do not need to resize any of your template's controls in
   -- this message. All resizing should be handled in resizeControl.
   
   
   
   set the text of field "City" of me to pDataArray["label 1"]
   set the text of field "State" of me to pDataArray["label 2"]
   put pDataArray["label 3"] into tDate
   set itemdel to "-"
   ## Re-arrange to normal english (non SQL) date order:
   put item 2 of tDate & "/" & item 3 of tDate & "/" & item 1 of tDate into tNewDate
   ## Now use LCs convert command:
   convert tNewDate to long date
   ## Now you can display the converted date:
   put tNewDate into field "Begins" of me 
   set the text of field "Title" of me to pDataArray["label 4"]
   set the text of field "Lane" of me to pDataArray["label 5"]
   set the text of field "Street" of me to pDataArray["label 6"]
   set the text of field "Link" of me to pDataArray["label 7"]
   set the text of field "Phone" of me to pDataArray["label 8"]
   set the text of field "Zipcode" of me to pDataArray["label 9"]
   set the text of field "Description" of me to pDataArray["label 11"]
   put pDataArray["label 12"] into cCat
   put  cCat into tFileName
   put "http://www.bowlingquest.com/wp-content/plugins/my-calendar/icons" into tFullPath
   put  tFullPath &"/"& tFileName into tFullPath
   set the filename of image "image" of me to tFullPath
end FillInData


on LayoutControl pControlRect
    local theFieldRect
    
    -- This message is sent when you should layout your template's controls.
    -- This is where you resize the 'Background' graphic, resize fields and 
    -- position objects.
    -- For fixed height data grid forms you can use items 1 through 4 of pControlRect as
    -- boundaries for laying out your controls.
    -- For variable height data grid forms you can use items 1 through 3 of pControlRect as
    -- boundaries, expanding the height of your control as needed.
        
    -- Example:
    put the rect of field "City" of me into theFieldRect
    put item 3 of pControlRect - 5 into item 3 of theFieldRect
    set the rect of field "City" of me to theFieldRect
    
    set the rect of graphic "Background" of me to pControlRect
end LayoutControl


on ResetData
    -- Sent when data is being emptied because the control is no longer being used to display data
    -- set the text of field "Label 1" of me to empty
    -- set the text of field "Label 2" of me to empty
    -- et the text of field "Label 3" of me to empty
    -- set the text of field "Label 4" of me to empty
    -- set the text of field "Label 5" of me to empty
end ResetData


on PreFillInData
    -- Sent right before new data is going to replace existing data in the control
end PreFillInData


setprop dgHilite pBoolean
    -- This custom property is set when the highlight of your custom template has
    -- changed. By default the "Background" graphic will be highlighted for you. 
    -- You only add script here if you want to further customize the highlight.
    
    -- Example:
    if pBoolean then
        set the foregroundColor of me to the dgProp["hilited text color"] of the dgControl of me
    else
        set the foregroundColor of me to empty
    end if
end dgHilite


getprop dgDataControl
    -- Required by library so that it can locate your control.
    return the long ID of me
end dgDataControl


on mouseDoubleUp pMouseBtnNum
    local theKey
    
    -- Example of how to edit the contents of a field.
    -- By passing the index of the record associated with copy of this template being displayed and
    -- a key (array key) the data grid will automatically save the changes the user
    -- makes and refresh the UI by calling FillInData and resizeControl.
    if pMouseBtnNum is 1 then
        if the dgProps["allow editing"] of the dgControl of me then
            switch the short name of the target
                case "Label"
                    put "Label 1" into theKey
                    EditFieldText the long ID of the target, the dgIndex of me, theKey
                    break                 
            end switch
        end if
    end if
    
    pass mouseDoubleUp
end mouseDoubleUp

Klaus
Posts: 11110
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Make Hyperlinks active

Post by Klaus » Mon Apr 11, 2016 11:39 am

You didn't:
1. set up any of your fields to be a hyperlink
nor
2. add any "mouseup" handler to "launch" that URL as described on page one of this thread.

Come on, what do you exspect? 8)

bbhank
Posts: 116
Joined: Thu Mar 17, 2016 6:04 pm

Re: Make Hyperlinks active

Post by bbhank » Mon Apr 11, 2016 3:03 pm

Yes I did. I followed the instruction in the tutorial. Used the message box. I tried where suggested which didn't work. The one post says they put it in the stack script. "for example, the handler below was placed in the stack script.".

As to what I "expect" - Workable answers. :wink:

Klaus
Posts: 11110
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Make Hyperlinks active

Post by Klaus » Mon Apr 11, 2016 3:21 pm

That was BEFORE we knew that we are talking about a datagrid! 8)

OK, do this:
1. Set the "linktext" property in the "fillindata" handler right after filling your field "Link" and
2. add the appropriate "mouseup" handler to that behaviour script.
As to what I "expect" - Workable answers.
Well, this requires asking the correct questions!

bbhank
Posts: 116
Joined: Thu Mar 17, 2016 6:04 pm

Re: Make Hyperlinks active

Post by bbhank » Mon Apr 11, 2016 3:29 pm

The question was correct. The question of whether this was a datagrid or not needed to have come first. :wink:

Klaus
Posts: 11110
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Make Hyperlinks active

Post by Klaus » Mon Apr 11, 2016 3:35 pm

bbhank wrote:The question was correct. The question of whether this was a datagrid or not needed to have come first. :wink:
The answers were completely correct to the questions you had asked!
And yes, your info whether this is a datagrid or not had to come first, so don't try to pass the buck to us! 8)

bbhank
Posts: 116
Joined: Thu Mar 17, 2016 6:04 pm

Re: Make Hyperlinks active

Post by bbhank » Mon Apr 11, 2016 3:52 pm

No buck is passed to you. I need all my bucks and then some! :) That's why I'm still working after 65.

Went to the dictionary on linkText but it doesn't say what to do if text is variable.

Klaus
Posts: 11110
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Make Hyperlinks active

Post by Klaus » Mon Apr 11, 2016 4:05 pm

bbhank wrote:Went to the dictionary on linkText but it doesn't say what to do if text is variable.
Because this is a property of a (chunk in a) field, as the dictionary tells you with:
...
Objects (or Types): field
...

bbhank
Posts: 116
Joined: Thu Mar 17, 2016 6:04 pm

Re: Make Hyperlinks active

Post by bbhank » Mon Apr 11, 2016 4:13 pm

OK. :? Please explain.

Klaus
Posts: 11110
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Make Hyperlinks active

Post by Klaus » Mon Apr 11, 2016 4:14 pm

Explain what?

bbhank
Posts: 116
Joined: Thu Mar 17, 2016 6:04 pm

Re: Make Hyperlinks active

Post by bbhank » Mon Apr 11, 2016 4:17 pm

Klaus wrote: Because this is a property of a (chunk in a) field, as the dictionary tells you with:
...
Objects (or Types): field
...
I'm trying to get the link in the field to be able to be clicked on and have it take you to the page in the link is all.

bbhank
Posts: 116
Joined: Thu Mar 17, 2016 6:04 pm

Re: Make Hyperlinks active

Post by bbhank » Tue Apr 12, 2016 12:25 am

Code: Select all

on mouseUp
launch URL the clickText
end mouseUp
I put this in the script for the field. Seems to work so far.

Thanks all. :)

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

Re: Make Hyperlinks active

Post by dunbarx » Tue Apr 12, 2016 1:35 am

Hi.

As you may have read farther back in the thread, this simple line does not discriminate what the clickText is. You will want to put one more small addition, to check the textStyle of the clickChunk, so that you do not try to launch URL "fleas".

You know how to do this, right?

Craig

bbhank
Posts: 116
Joined: Thu Mar 17, 2016 6:04 pm

Re: Make Hyperlinks active

Post by bbhank » Tue Apr 12, 2016 2:03 am

Never heard of em.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

Re: Make Hyperlinks active

Post by Dixie » Tue Apr 12, 2016 2:05 am

Never heard of em.
they make you itch...:-)

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”