Datagrid: multiple hilites

David Bovill david.bovill at gmail.com
Sat Oct 17 11:00:25 EDT 2009


2009/10/17 Trevor DeVore <lists at mangomultimedia.com>

>
> There are some scrolling handlers that are documented:
>
> ScrollIndexIntoView/ScrollLineIntoView
>
> There is also an undocumented ScrollRectIntoView command you can find in
> the Data Grid button. You might want to take a look at those.
>

Thanks - but "ScrollRectIntoView" would rely on "## See dgRectOfIndex in
order to get rect of a control in the data grid." - and this is broken for
cases in which the rows are scrolled above the grid (perhaps when they go
above the screens top?) -- see the handler below for a temporary fix.

getprop dg_ScrollTop [lineNum]
>    if lineNum < 2 then return 0
>    put the dgControl of the target into dataGrid
>    if exists(dataGrid) is false then return empty
>
>    if the dgprop ["fixed row height"] of dataGrid is true then
>       -- not tested yet!
>       put the the dgprop ["fixed row height"] of dataGrid into
> fixedRowHeight
>       put (lineNum - 1) * fixedRowHeight into scrollTop
>    else
>       get the dgVisibleLines of dataGrid
>       put item 1 of it into firstVizLine
>       put item 2 of it into lastVizLine
>
>       switch
>          case lineNum < firstVizLine
>             if the dgprop ["cache controls"] of dataGrid is false then
> return empty
>             put 0 into scrollTop
>             repeat with someLineNum = 1 to lineNum
>                put the dgIndexOfLine [someLineNum] of dataGrid into
> someIndexNum
>                put the dgRectOfIndex [someIndexNum] of dataGrid into
> rectOfIndex
>                put item 4 of rectOfIndex - item 2 of rectOfIndex into
> recordHeight
>                add recordHeight to scrollTop
>             end repeat
>             break
>          default
>             put the dgIndexOfLine [lineNum] of dataGrid into indexNum
>             put the dgRectOfIndex [indexNum] of dataGrid into rectOfIndex
>
>             put item 2 of rectOfIndex into recordTop
>             if recordTop is empty then
>                -- problem here as the "row" (record view) does not exist so
> cannot get its height!
>                return empty
>             end if
>             put recordTop - the top of dataGrid into scrollTop
>       end switch
>    end if
>
>    subtract 3 from scrollTop -- just a tweek to show a margin
>    return scrollTop
> end dg_ScrollTop
>



More information about the use-livecode mailing list