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!
Thank you Craig,
itemOffset is not at all what I am after.
The clickline gives for example, line 2 of field 1 (as I stated in my question)
I want the line number and the item (or column) number.
I want to be able to perform one action if it is a column 1 selection (of whatever line it was).
or a different action if it was column 2 selection (of whatever line it was).
on mouseup
put word 2 of the clickLine into tLine
put the value of the clickLine into tText
put the clickText into tValue
set the itemDel to tab
put itemOffset(tValue,tText) into tItem
answer "You clicked column" && tItem && " of line" && tLine && "which contained" && quote & tValue & quote
end mouseup
It is verbose, but that is for informational purposes. Write back if you still need help.
Yes Craig, that achieves the objective.
I sss the offset is the important part of this (from my point of view) so I will study how this works.
I had hoped the process to find the column was as simple, if not part of the Clickline output. Perhaps there should be a clickeditem command or function.
Hi Craig,
I have looked at the offset in the dictionary.
I see a real snag here, because if column 1 has the same content as column 2, and it was column 2 that was clicked, the wrong column will be reported.
Regretably, this is not what I need to solve the problem.
I can see a kluge here using item 2 of "the clickLoc", and it would be a simple task to implement, even if you change the tab stops in the table field. Can you see it?
But maybe the best way forward from here is to change to a dataGrid. There are built-in properties that will give you the column and row directly. These are big gadgets, dataGrids are, and take a little practice, but if you only use their basic features, you can get running quickly.
on mouseup
wait 0 with messages -- needed for all setprops/getprops in the table to finish
put the cRevTable["currentxcell"] of field 1 -- will put the x position into the message box
put cr & the cRevTable["currentycell"] of field 1 after msg -- will put a cr and the y position into the message box by querying the current x or y cell property from the custom property set of the table.
end mouseup
on mouseup
put item 1 of the clickLoc into tLoc
put the tabstops of me into tStops
put tLoc div tStops into tColumn
answer tColumn
end mouseup
Nice simple method!
Also bipasses the issue where the user might click into the cell but miss the text (leaving the clickchunk empty) Potential trouble if the tabstops aren't uniform but that could be gotten around. Also, if the table isn't positioned at the left edge of the card an adjustment would need to be made to account for that since the clickloc is card based not object based. All manageable issues, and probably better than using undocumented features.
I mean my solution is undocumented. using the cRevTable properties to get the clicked cell. Had to dig through some old stuff in the mailinglist archive to find it.
the cRevTable["currentxcell"] will contain the current x posotion, and currentycell will have y of course. But i'm usually a bit leery of using the underlying "may change at any moment" stuff, especially with so many changes coming down the pipe "real soon now".
Table fields come out of the box with a single tabstop preset. If you check the dictionary, you will see that each column can have its own width, settable by a comma delimited list of tabstops, that list being a property of the field. So if you had different stops set in your table field, you would have to modify my simple script, which assumes a constant stop value.
Do you have custom tab stops? If so, can you handle the modification?