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: FourthWorld, heatherlaine, Klaus, kevinmiller
-
user#606
- Posts: 217
- Joined: Sun Jan 27, 2008 12:25 pm
-
Contact:
Post
by user#606 » Sat Mar 23, 2013 4:13 pm
I can get the line and field value with
Code: Select all
on mouseup
set itemdelimiter to tab
answer the clickline
end mouseup
but I need the
line and
item value
I have looked in the dictionary, User Samples, Tutorials, Resources and cannot find this.
Also, the table settings are critical to pinpointing the cell and not the whole line.
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10331
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Sat Mar 23, 2013 4:21 pm
Hi.
It looks like you can do this.
Check out "itemOffset" in the dictionary. You can get what you need in about three lines of code in your mouseUp handler.
I see you already have the clickLine. So what are you missing in that regard?
Craig Newman
-
user#606
- Posts: 217
- Joined: Sun Jan 27, 2008 12:25 pm
-
Contact:
Post
by user#606 » Sat Mar 23, 2013 4:47 pm
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).
I hope that clarifies.
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10331
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Sat Mar 23, 2013 5:06 pm
Unless I still do not get you, try this in the script of your table field. It has the gadgets we just spoke of:
Code: Select all
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.
Craig Newman
-
user#606
- Posts: 217
- Joined: Sun Jan 27, 2008 12:25 pm
-
Contact:
Post
by user#606 » Sat Mar 23, 2013 5:24 pm
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.
Thanks again, I can now progress.
-
user#606
- Posts: 217
- Joined: Sun Jan 27, 2008 12:25 pm
-
Contact:
Post
by user#606 » Sat Mar 23, 2013 5:30 pm
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.
Any other ideas?
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10331
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Sat Mar 23, 2013 6:18 pm
Good testing.
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.
Try one:
http://lessons.runrev.com/s/lessons/m/d ... =Data+Grid
and
http://lessons.runrev.com/s/lessons/m/datagrid
Write back about which way you went. Hopefully both.
Craig Newman
-
sturgis
- Livecode Opensource Backer

- Posts: 1685
- Joined: Sat Feb 28, 2009 11:49 pm
Post
by sturgis » Sat Mar 23, 2013 6:32 pm
You can do this:
Code: Select all
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
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10331
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Sat Mar 23, 2013 6:35 pm
The kluge is not too onerous:
Code: Select all
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
-
user#606
- Posts: 217
- Joined: Sun Jan 27, 2008 12:25 pm
-
Contact:
Post
by user#606 » Sat Mar 23, 2013 6:39 pm
Hi Craig,
I will read up on the suggestions you have made and perhaps, implement something along those lines, later.
Many thanks for your help.
Also thanks to Sturgis, I have just noticed your message.
-
sturgis
- Livecode Opensource Backer

- Posts: 1685
- Joined: Sat Feb 28, 2009 11:49 pm
Post
by sturgis » Sat Mar 23, 2013 6:43 pm
dunbarx wrote:The kluge is not too onerous:
Code: Select all
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.
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10331
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Sat Mar 23, 2013 7:01 pm
Sturgis.
Quite so about the clickLoc.
606, do you see what he means, and what I left out?
But Sturgis, where is this undocumented info not documented?
Craig
-
sturgis
- Livecode Opensource Backer

- Posts: 1685
- Joined: Sat Feb 28, 2009 11:49 pm
Post
by sturgis » Sat Mar 23, 2013 7:06 pm
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".
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10331
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Sat Mar 23, 2013 7:08 pm
606:
Something else Sturgis mentioned...
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?
Craig Newman