I sent a badly constructed message with this content (more or less) a few days 
ago.  I am re-posting it in the hope that anyone who tried to decipher those 
two messages will give this another consideration.

So pardon the repeat, but I'm quite sure someone from this group can lend me a 
hand on this issue.

Using LC v8.1.9 on Windows 7 pro

Using a datagrid form, each row has 1 checkbox, 3 fields and 2 buttons.

One of the buttons (the one I need assistance with), named "Query" calls the 
"tsnet" library to query a remote WiFi module (esp8266) which returns the 
status of one of its IO pins.  Works like a charm on ALL rows, scrolled or 
not... because (I reckon) the button is actually *IN* the grid, so there's no 
issue with the group name (as will become clear in a moment).. it is always 
"me".

I also want to "automate" the queries (there are 8 such wifi modules involved). 
 So I have a button outside of the datagrid which selects each row of the 
populated datagrid in a "repeat" statement and sends a "mouseUp" message to the 
datagrid.

What I discovered is that (apparently) I have to "manufacture" the group name 
of each row to which I want to send the "mouseUp" message.  So as I progress 
through the populated rows of the grid the "pseudo" group name of each row 
basically becomes the row number along with a prefix of "Row Template"... i.e. 
row 1's group name/label is "Row Template 0001", row 2 is "Row Template 0002", 
etc.

Great... but once the grid starts to scroll, strange things start to happen.  
The pseudo-group name will "wrap"... and where it wraps depends on the number 
of rows which are initially visible on the grid.

For example, if there are 8 populated rows and the DataGrid is sized to only 
show 3 rows at a time, upon the initialization of the Datagrid, the "pseudo" 
Row templates groups are named:

row 1:  "Row Template 0001" 
row 2:  "Row Template 0002"
row 3:  "Row Template 0003"
row 4:  "Row Template 0004"
row 5:  "Row Template 0005"
row 6:  "Row Template 0001"
row 7:  "Row Template 0002"
row 8:  "Row Template 0003"

this is demonstrated by putting a "put me" in the Behavior Script within the 
MouseUp handler to which I am sending the "mouseUp" message in order to 
"process" that row's content... i.e.

on mouseUp
        put me
        ...do something
end mouseUp

What is interesting (and confusing at the same time), if I use a specific 
"wrapping pattern" (such as the one described above) and mutually "wrap" the 
name of the group to which I am about to send the "mouseUp" message, it works!  
... i.e. from within the button outside of the datagrid:
... (in this example, the serverList array holds the 8 wifi module names I need 
to query with tsnet)

put "0000" into pad
put 0 into q
repeat with y = 1 to (the number of lines in the keys of serverList)
   set the dgHilitedLines of group "DataGrid 1" to y
   add 1 to q
   if q > 5 then put 1 into q
   put char 1 to (4 - length(q)) of pad & q into z
   put char 1 to (4 - length(y)) of pad & y into z
   put "Row Template " & z into z
   send "mouseUp" to button "Query" of group z
end repeat

THIS is confusing because, although I am sending the same message to what 
appears to be the same pseudo-group name, once the grid scrolls beyond row 5, 
LC manages to know that I am actually referencing another grid row than the 
one(s) with the same pseudo-group names.

To scroll the grid, programatically, I used:
   set the dgHilitedLines of group "DataGrid 1" to y  
to accomplish this.

I also tried the more "seemingly appropriate":
   dispatch "ScrollLineIntoView" to group "DataGrid 1" with pLine" 

but this command changes the highlight of one of my fields which I have 
customized to have red text in case of an error.  Regardless, using either 
method for scrolling does NOT seem to have any effect on the wrapping of the 
pseudo group name.

Since this "wrap-point" changes based on the "amount" of the datagrid I 
"expose", this doesn't lend itself to portable or supportable code.

If I don't "wrap" my group names according to this sort of pattern, once my 
code reaches the 6th line (in my example), I get a:
" ... Chunk: can't find background), char 1 " error ... because "Row Template 
0006" does not exist... it is "Row Template 0001"

No doubt I'm approaching this wrong but I'm trying to teach myself datagrids 
and it's a struggle for this old brain!
Is there another method for sending a "mouseUp" to a button on a datagrid form 
row?

Douglas Ruisaard
Trilogy Software
(250) 573-3935



Douglas Ruisaard
Trilogy Software
(250) 573-3935




_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to