Datagrid scrolling question

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

Post Reply
phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Datagrid scrolling question

Post by phaworth » Thu May 13, 2010 7:17 am

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

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Re: Datagrid scrolling question

Post by trevordevore » Thu May 13, 2010 2:42 pm

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
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

Post Reply