[Datagrid] How to manage the empty area outside the selectable lines?

Trevor DeVore lists at mangomultimedia.com
Mon Apr 26 13:09:16 CDT 2010


On Apr 24, 2010, at 6:31 PM, zryip theSlug wrote:

> What is my best alternative if I assume that I have seen nothing in
> the API to manage this empty area?

Hmm, it looks like a couple of additional properties would help here.  
You need to know if 1) you clicked on a row or 2) you clicked in the  
area where data is displayed.

I've added the following to the Data Grid in 4.5 :

the dgClickLine
the dgClickIndex
the dgClickedInDataView

To check if the user clicked in an empty area you would do the  
following in a data grid script:

if the dgClickedInDataView of me and the dgClickIndex of me is empty  
then
     ## clicked in empty area
end if

I'm including the relevant code to the end of this email if you want  
to add it to your own data grid script. Just edit the script of btn  
"Data Grid" of stack "revDataGridLibrary".

> About this, by testing this solution, I seen an odd behavior with
> inactive horizontal scrollbars. When you click on the scrollbar and
> have lines in the datagrid, you select the corresponding line. Is it
> totally normal?

No, not normal. I just tested this and noticed that rev does not  
report a scrollbar as the target of a mouseclick if the scrollbar  
thumb is not visible. I'm not sure why this is but it is what it  
is :-) I've added a workaround for this to the data grid code for 4.5.

-- 
Trevor DeVore
Blue Mango Learning Systems
ScreenSteps: http://www.screensteps.com
Releasable Revolution Resources for Developers: http://revolution.bluemangolearning.com


===========================

getprop dgClickLine
    put the dgClickIndex of me into theIndex
    if theIndex > 0 then return the dgLineOfIndex[theIndex] of me
    else return empty
end dgClickLine


getprop dgClickIndex
    ## figure out the index clicked on
    put empty into theIndex
    put _RowControlClickedOn() into theControl

    if theControl is not empty then
       put the dgIndex of theControl into theIndex
    end if
    return theIndex
end dgClickIndex


getprop dgClickedInDataView
    ## Note that Rev doesn't report scrollbars as mousecontrol if  
thumb is not
    ## showing. Hence the checks for visibility and click not within  
of vertical scrollbar
    ## (dglist overlaps with rect of vertical scrollbar)

    put the clickLoc into theClickLoc
    return theClickLoc is within the rect of group "dgListMask" of me \
           and (not the visible of scrollbar "dgScrollbar" of me \
           or (the visible of scrollbar "dgScrollbar" of me and  
theClickLoc is not within the rect of scrollbar "dgScrollbar" of me))
end dgClickedInDataView


private function _RowControlClickedOn
    local theControl

    ## figure out the index clicked on
    put the dgDataControl of the target into theControl

    ## Make sure user clicked in valid area.
    if theControl is empty and the dgClickedInDataView of me then
       ## Perhaps no column in clicked area or no mouse receiving  
controls in column
       put the clickV into theY
       repeat for each line thePotentialControl in  
_ListOfVisibleControls()
          put the rect of thePotentialControl into theRect
          if theY >= item 2 of theRect and theY <= item 4 of theRect  
then
             put thePotentialControl into theControl
             exit repeat
          end if
       end repeat
    end if

    return theControl
end _RowControlClickedOn 



More information about the use-livecode mailing list