Get list of controls of hilited row of datagrid
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 15
- Joined: Tue Aug 18, 2015 6:48 am
Get list of controls of hilited row of datagrid
Hi,
I have a datagrid with multiple image field inside the row template.
I need to loop thru all the image controls of the hilited row of the datagrid.
Can any expert please show me how to do it.
Regards,
Francis
I have a datagrid with multiple image field inside the row template.
I need to loop thru all the image controls of the hilited row of the datagrid.
Can any expert please show me how to do it.
Regards,
Francis
-
- Posts: 15
- Joined: Tue Aug 18, 2015 6:48 am
Re: Get list of controls of hilited row of datagrid
Sorry, I forget to mention that I need to loop thru all the image control inside the hilited row in the on mouseUp event.
Re: Get list of controls of hilited row of datagrid
Hi Francis,
1. welcome to the forum!
2. Please stick to the correct Livecode terms to get precise help!
"multiple image field"? image <> (TEXT) field
Sorry, no idea what you are trying to do?
Best
Klaus
1. welcome to the forum!

2. Please stick to the correct Livecode terms to get precise help!
"multiple image field"? image <> (TEXT) field
Sorry, no idea what you are trying to do?
Best
Klaus
Re: Get list of controls of hilited row of datagrid
Assuming the name of the image controls are image1-5:
Klaus is right by the way, a field control is different from an image control, guess you mixed them up :p
Code: Select all
on mouseUp
local theLine,theData
put the dgHilitedLines of group "myDataGrid" into theLine
put the dgDataOfLine[theLine] of group "myDataGrid" into theData
repeat for each element tImage in theData
local x
add 1 to x
set the text of img "previewImage" to tImage["image"&x] -- or whatever else you need to do with it
end repeat
end mouseUp
Knowledge is meant to be shared.
-
- Posts: 15
- Joined: Tue Aug 18, 2015 6:48 am
Re: Get list of controls of hilited row of datagrid
Hi,
Sorry. I mean image control.
Basically in my row template, I have 3 image control.
when there is a mouse click directly on the visible non-transparent portion of the image, i can detect it.
But unable to detect when there is a mouse click on the transparent portion of the image. I understand this is the correct behaviour but hope to bypass this limitation.
So what I'm trying to do is to get loop thru all 3 image control and check if the mouseloc is within any of the rect of these image control in the hilited row.
I also can't replace the image control with a button control as the images are reference to image files in a folder.
Regards,
Francis
Sorry. I mean image control.
Basically in my row template, I have 3 image control.
when there is a mouse click directly on the visible non-transparent portion of the image, i can detect it.
But unable to detect when there is a mouse click on the transparent portion of the image. I understand this is the correct behaviour but hope to bypass this limitation.
So what I'm trying to do is to get loop thru all 3 image control and check if the mouseloc is within any of the rect of these image control in the hilited row.
I also can't replace the image control with a button control as the images are reference to image files in a folder.
Regards,
Francis
Re: Get list of controls of hilited row of datagrid
Hi Francis,
in that case, I would put an opaque graphic behind each image, with the same "rect" as the image!
Then I would give them clever names so I can see if a "clicked" graphic actually "belongs" to a specific image.
Know what I mean?
Best
Klaus
in that case, I would put an opaque graphic behind each image, with the same "rect" as the image!
Then I would give them clever names so I can see if a "clicked" graphic actually "belongs" to a specific image.
Know what I mean?
Best
Klaus
-
- Posts: 15
- Joined: Tue Aug 18, 2015 6:48 am
Re: Get list of controls of hilited row of datagrid
Hi Klaus,
Other than putting an opaque image behind, is there any way of looping thru the image control of the hilited row?
Regards,
Francis
Other than putting an opaque image behind, is there any way of looping thru the image control of the hilited row?
Regards,
Francis
Re: Get list of controls of hilited row of datagrid
Not sure if i understood wrong but isnt this what you'r looking for?
-- this script inside the card
-- this script inside the card
Code: Select all
on mouseUp
if the mouseLoc is whithin the rect of "image1" then -- or whatever if not image1
-- do something
else if the mouseLoc is whithin the rect of "image2" then
-- do something
else if the mouseLoc is whithin the rect of "image3" then
-- do something
end if
pass mouseUp
end mouseUp
Knowledge is meant to be shared.
-
- Posts: 15
- Joined: Tue Aug 18, 2015 6:48 am
Re: Get list of controls of hilited row of datagrid
Hi Zaxos,
There will be multiple rows inside the datagrid with the same image name (same name as inside the row template, only the id will be different for each row)
For my case, I need to loop thru only the image control of the hilited row.
Regards,
Francis
There will be multiple rows inside the datagrid with the same image name (same name as inside the row template, only the id will be different for each row)
For my case, I need to loop thru only the image control of the hilited row.
Regards,
Francis
Re: Get list of controls of hilited row of datagrid
Maybe this helps:
And after that:
I tryed the first code and it returns only the controls of the hillited line. Guess thats what you wanted, wish you the best.
Code: Select all
on getData
put the dgHilitedIndex of grp "sampleForm" into theIndex
put the dgDataControlOfIndex [theIndex] of grp "sampleForm" into tControl
put the name of tControl into tOwner
repeat with x = 1 to the number of controls
if the owner of control x is tOwner then
put the long ID of control x&return after tControls
-- or put "control"&&x&return after tControls if what you need is the control number
-- or put the name of control x&return after tControls
end if
end repeat
delete last char in tControls
end getData
Code: Select all
on mouseUp
getData
repeat for each line tControl in tControls
if the mouseLoc is within the rect of tControl then
put tControl
end if
pass mouseUp
end mouseUp
Knowledge is meant to be shared.