0

I have a field with card names. Each card name is on its own line. The field is locked. I would like to have a script for the field which executes

go to card tName

where tName contains the content of the line on which the user clicked.

This question leads to an implementation alternative for the question

How do I create an array of buttons with a script?

Community
  • 1
  • 1
z--
  • 2,186
  • 17
  • 33

4 Answers4

1

Use the following in your locked field you're using as a menu:

go to cd the selectedText of fld "<your-locked-field-name-here>"
  • This is a partial answer. It works if I manually select the name of the card. But I would like to click on a line to go to the card which has the same name as the content of the clicked line. So we need an expression which selects the whole line which has been clicked. – z-- Jun 15 '13 at 17:22
1

The hilitedline will work if the cards are in the same order as the list in the field. If they aren't you can do this instead:

get the text of the clickline
go card it
Jacque
  • 416
  • 2
  • 7
  • Yes it works fine. Your answer combined with the modified version of the preOpenStack script of Mark gives a nice clickable 'Table of Contents' field. – z-- Jun 17 '13 at 16:35
  • Actually both Mark and you should have the answer accepted. However as you just started answering I give it here. – z-- Jun 17 '13 at 16:36
0

Create a list style field. It will automatically highlight the line you click. Then use this handler in the field script:

on mouseUp
   get the hilitedText of me
   go card it
end mouseUp
Devin
  • 593
  • 1
  • 3
  • 8
  • I should have mentioned that a list style field is just a field with its listBehavior property set to true. – Devin Jun 16 '13 at 04:21
  • This won't work, because the hilitedLine returns a number. If you change the order of the list of card names in the field, you'd go to the wrong card. – Mark Jun 16 '13 at 07:24
  • 1
    Of course, you're right, Mark. Never try to give a solution when you're tired. It should have been: 'get the hilitedText of me'. – Devin Jun 17 '13 at 02:30
  • Devin, you may edit your answer and correct it. Then I happily will click the "upvote" button. – z-- Jun 17 '13 at 09:47
0

Create a list field and add the names of the cards to it. You can do this automatically with this script:

on preOpenStack
  repeat with x = 1 to number of cards
    put the short name of cd x & cr after myList
  end repeat
  put myList into fld "Your List FIeld"
end preOpenStack

Now you can put any of the following lines into a mouseUp handler of your list field:

go cd value(the clickline)
go cd (the text of the hilitedLine of me)
go cd (the selectedText)

There may be additional possibilities.

Mark
  • 2,380
  • 11
  • 29
  • 49
  • The preOpenStack script works if you have ` put the short name of cd x & return after myList` – z-- Jun 17 '13 at 16:19
  • For the mouseUp handler I had to use the version of Jacque : get the text of the clickline -- go card it – z-- Jun 17 '13 at 16:34
  • 1
    Yup, I forgot to write a small piece of the syntax. I've added it. – Mark Jun 17 '13 at 22:25