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

Andre.Bisseret Andre.Bisseret at inria.fr
Sun Apr 25 11:57:47 EDT 2010

Le 25 avr. 10 à 00:31, zryip theSlug a écrit :

> Hi all,
> I'm actually working with datagrids.
> First of all, I think that I have to explain my question, so:
> Basically a datagrid is divide in 4 parts:
> - headers
> - scroll bars
> - lines of data (that I call "the selectable lines")
> - area with no data (that I call "the empty area outside the  
> selectable lines")
> I would like to manage this empty area. I planned to add a new line
> when an user double click in it.
> For doing that, I created this code in the datagrid script:
> on mouseDoubleUp
>   If ((the dgHeader of the target is empty) and \
>     (the short name of the mouseControl is not "dgCornerPiece"))  then
>      dg_AddNewLine long id of me,"last",true --C
>      put the dgNumberOfLines of me into tCurrentRow
>      set the dgHilitedLines of me to tCurrentRow
>      dispatch "EditCell" to me with line 2 of the cColumnNames of me,\
>                                                  tCurrentRow
>   end if
> end mouseDoubleUp
> I have difficulties with the scroll bars. When they exists but are not
> active (because the list is too small), they traps the double click
> and performs the creation of the new line.
> What is my best alternative if I assume that I have seen nothing in
> the API to manage this empty area?
> No doubt someone has already doing that. ;)
> I have already give a try to the mouseControl function but it not
> returns the scrollbar control because the datagrid bg objects rides
> the scrollbar.

Bonjour TheSlug,

You are right; I am fighting with that for a while without any success  
(so my post won't not help much ;-((
If one write (in the dg script :
on mouseUp
put the target
end mouseUp

one get,
when clicking 	on the headers line: graphic "dgBackground"
		""		on the Hscrollbar: graphic "dgBackground"
		""		on the rows part: graphic "dgAlternatingRows"
		""		on the VscrollBar: graphic "dgAlternatingRows"

So it is possible to get "insensible" header line, horizontal scroll  
bar and the cornerPiece (bravo! sure I would not have think to this  
one ;-))

Thus one can script:

on mouseUp
    if the short name of the target is not in  
"dgBackground,dgCornerPiece" then
       if the dgIndex of the target is empty then beep 3 -- here  
dispatch "addLine" etc.
    end if
end mouseUp

but the V scroll bar continue to beep like the empty rows part (even  
if one click beside a row whose is not empty)

I tried different tricks but seems really impossible to distinguish  
the V scroll bar area from the rows area!!! (might be missing  

> 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?
Right again! I did not noticed that before; seems not normal at all  

Sorry no great help! only confirmation (and for me, learning;  
thanks ;-))

Best regards from Grenoble


More information about the Use-livecode mailing list