Page 1 of 1

Recognising a line in a Table Field

Posted: Wed Oct 14, 2009 7:55 pm
by exheusden
I have a Table Field, which I fill with titles and card IDs (each line contains a title and its corresponding card ID): the contents appear correct in the Contents panel of the Inspector.

I have checked List behavior in Basic Properties.

I want to be able to click on a selected title and go to the relevant card, identified by the corresponding Card ID.

Problem: I am unable to obtain the contents of the clicked line.

Clicking on a line highlights the text. However, the clickLine appears to be empty; the selectedText returns only the title; the selectedLine returns "line 1 of field 5" irrespective of which line is clicked (and the stack does not contain a field 5, which is disconcerting); the hilited line of me seems to be ignored when used in the field script, but indicates the correct highlighted line when used from the message box.

What must I do in order to receive the complete line (both "cells" in other words)?

Posted: Wed Oct 14, 2009 8:25 pm
by bn
Hi exheusden,
this should work for a table field
set the script of the field to

Code: Select all

on mouseUp
   put the clickline into msg
   put return &  value (the clickline) after msg
   set the itemdelimiter to tab
   put return & item 1 of value (the clickline) && item 2 of value (the clickline) after msg
end mouseUp
this puts the clickline, the content of the clickline and item 1 and 2 of the content of the clickline into the message box. Since the colums of a list field are separated by tabs, I used tab as the itemdelimiter to figure out item 1 and 2, your title and card ID respectively.
Now about your magical field 5, I don't know.
regards
Bernd

Posted: Wed Oct 14, 2009 9:05 pm
by exheusden
Yes, that's just about what I had originally and, like my own coding, it returns nothing at all. I have tried quitting and restarting Revolution, too, but still nothing. Indeed, if the message box isn't open, it simply doesn't show (and if it is open, nothing extra appears in it).

The stack is a small thing, with just one card containing 4 fields: the table and two other fields that are used for another function, as well as a testing field that I used because I thought there was a problem with the message-box (as nothing was being displayed in it). The only field with a script is the table field; at the moment it has only the on mouseUp script suggested by your good self. The only other script is an on keyDown at stack level.

Posted: Wed Oct 14, 2009 9:09 pm
by exheusden
I think I've found the solution.

In the Basic Properties panel for the Field Table, the Lock text must be checked. Will try it now.

Edit: yes -- it works!

Posted: Wed Oct 14, 2009 9:10 pm
by bn
could you make a new stack with just the table field with the script in it and try that. It baffles science...
regards
Bernd

Posted: Wed Oct 14, 2009 10:02 pm
by exheusden
Bernd, just made a new stack with only a table field; I checked List behavior and noticed that the Lock text attribute was already checked. Presumably, I had managed to uncheck that attribute, which did not get automatically rechecked when List behavior was reselected. That's that problem more or less out of the way (should Lock text be automatically checked when List behavior is checked?), but as for field 5… no idea.

Posted: Wed Oct 14, 2009 10:12 pm
by bn
if a field, table or any other type, is does not have the loctext set to true it does not get mouse messages, because one presumably wants to type in it. Instead such a field get a openfield message.

If you create a table field by default locktext is disabled (dimmed) because in the property inspector under table cellediting is true. If you unselect cellediting and go to basic properties and select listbehavior locktext is unchecked. So you would have to manually check the locktext.
Oh well, such are the joys of coding.
regards
Bernd