Page 1 of 1

Datagrid scrolling question

Posted: Thu May 13, 2010 7:17 am
by phaworth
I'm looking for a way to figure out whether the hilited line of a datagrid is visible when the user stops scrolling the lines in the datagrid. I think I can do it by checking if the dgHilitedLine is between the two values returned by the dgVisibleLines property of the datagrid but I can't figure out when and where to make that check.

Any ideas?

Thanks,
Pete

Re: Datagrid scrolling question

Posted: Thu May 13, 2010 2:42 pm
by trevordevore
If you are just monitoring the scrollbar then add a mouseUp handler to the data grid group script.

Code: Select all

on mouseUp pBtnNum
    if pBtnNum is 1 and word 1 of the target is "scrollbar" then -- works for both horizontal and vertical scrolling
        -- user released scrollbar
    end if
end mouseUp
This doesn't take into account using the arrow keys or home/end/page up/page down keys.

Another approach might be to process the command that performs the actual scroll: _ScrollListV. Something like this in the Data Grid group script would trigger a command that can monitor the lines being changed.

Code: Select all

command _ScrollListV
   -- if you just want to process when user finishes scrolling then cancel any messages
   -- with "CheckMe" in them at this point.

   send "CheckMe" to me in 20 milliseconds
   pass _ScrollListV
end _ScrollListV


on CheckMe
   -- todo: cancel any pending messages with "Checkme" in them
   
   -- Check if line is in site
end CheckMe