I ran into this when I started out trying to make a datagrid operate like a 
simple spreadsheet. Turns out it is not a simple thing to do. You would have to 
trap for a returnkey in any cell in the last row, or a tabKey in the last cell 
of the last row, and call addLine followed by editCellOfIndex (does addLine 
return the index or line created by chance?). 

To address clicking, you would have to calculate how many rows down the user 
clicked from the actual data, and then insert a bunch of blank data, which 
begins to mess things up tremendously, especially when the user tries to sort! 

Datagrids should, in my opinion, have a little vertical bar at the beginning of 
each row to indicate if there is data of any kind in the row. At least you 
would have a visual indication that there are blank rows there. 

Alternately, you could modify the datagrid drawing routine to add blank rows to 
fill up the visual space at the end of the data, but then you would have to 
modify the sort routines to ignore blank rows, or offer a parameter to the sort 
function to do so. Also the functions to return how many rows in the data would 
have to be modified, what gets returned with dgData and dgText, etc. 

As you can see, the whole problem gets really ugly, so as it turns out, making 
a datagrid operate like even a simple spreadsheet is anything but simple. What 
is REALLY needed is for the drawing routine to create the objects to fill in 
the visible area, but NOT have it effect the actual data itself until something 
is actually PUT in a row. At least for Table type datagrids anyway. This would 
probably require a reworking of the datagrid functions quite a bit so I am not 
holding my breath for this one. :-) 

You really get a glimpse of what a complicated thing a spreadsheet is in the 
first place! 

Bob


On Sep 6, 2011, at 11:29 AM, Pete wrote:

> You can tell if the user clicked in the header by checking "the dgHeader of
> the target" - it will be empty if the user did not click on the header, the
> long ID of the group containing all the column headers if the user clicked
> on the header.  If the user clicked on a specific column header rather than
> the empty area of the header to the right of the columns, the
> dgHeaderControl of the target contains the long ID of the column header
> control.
> 
> Never thought about detecting a click in the scrollbar, not sure how you
> would rule that out.
> 
> Personally,I prefer to provide a button for the user to click on to add a
> new row of data to a datagrid, just seems more user friendly to provide a
> visual clue as to how to add a row than leave the user to guess that a
> double click in an empty row of the datagrid is the way to do it.  With the
> button approach, you avoid having to scroll through a bunch of rows to get
> to the end of data and see an empty row, in fact there won't be an empty row
> if the total number of rows of data is an exact multiple of the number of
> visible rows in the datagrid.
> 
> Pete
> Molly's Revenge <http://www.mollysrevenge.com>
> 
> 
> 
> 
> On Tue, Sep 6, 2011 at 10:41 AM, Bob Sneidar <b...@twft.com> wrote:
> 
>> It is possible to determine that a click or double-click in the datagrid
>> was not in an active row with data. Just get the dgHilitedLine(s) inside a
>> mouseUp or doubleMouseUp handler. If it's empty the user clicked or double
>> clicked in an empty space in the dataGrid. Trouble is, it works equally well
>> for clicks in the header and scrollbar too. :-)
>> 
>> Bob
>> 
>> 
>> On Sep 4, 2011, at 6:48 AM, Matthias Rebbe wrote:
>> 
>>> Hi,
>>> 
>>> what do i have to do to let my user to add a new row to a DataGrid table?
>> I can edit an existing row(with already text in it), but i cannot add a new
>> line to the grid by clicking into the next empty row.
>>> Is that not possible?
>> 
>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
>> 
> _______________________________________________
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to