Click Table

Jim Ault JimAultWins at yahoo.com
Thu Feb 22 13:01:57 EST 2007


On 2/22/07 8:38 AM, "John Runde" <runde at uwplatt.edu> wrote:

> I am doing some financial programming.  Of prime importance, is a a
> Spreadsheet like field... I will call a "click field".  It is a
> crucial piece of my project, and I have not been able to get it to
> work.  Note that I am an accountant, not a programmer (but an old
> hand at hypercard).
> 
> Here are the criteria I need:
> 
> 1. a table field
> 2. the field is locked
> 3.  when you click on a cell, the row, column (item,line), should be
> placed in the top, leftmost cell (i.e. "1,1").  This cell will be
> reserved for this purpose.
> 4.  the table should scroll both H and V
> 5.  I should be able to resize the table as needed (for various cards).
> 6.  I will use code to populate the click field, it would be nice if
> the field would auto adjust for column width.
> 
> This seems so simple, yet I cannot get it to work.  It has to have
> something to do with properties, but danged if I can figure out
> what.  I tried about every property setting in combination, but to no
> avail.
> 
> Can someone program the above and either email it to me, or give me
> the details. 
In Rev, it is not simple.
There is no real table object, yet.  There are plans to do this, but not
likely in the near future.  I understand you want the user experience to be
very much like using a spreadsheet.

Most of us are familiar with the Excel spreadsheet which is optimized,
operates with tons of code behind it, and is far more versatile than a Rev
field will ever be.

You might take the approach of putting your calculated values into a
substack that is the size of the screen, remains invisible to the user,
contains the actual 'table field', then you 'import snapshot' of the rect of
that table field into the main stack, put that image into a group (setting
the H & V scrollbars to true).  Now the user can see the numbers, scroll,
click, and you can adjust the size of the rect of the group.

The user click location could retrieve the actual number from the substack
field and put it into a 'display field' at 1,1 as in
get item 6 of line 5 of fld numberGrid

For the column width adjust, you would need to get the formattedwidth of the
number in each cell, then adjust the max/min tab stop values for each
column, then import the snapshot of the filled rows and columns.

As you can see, this is not really simple.  I avoid using the table object,
but in your case, you are trying to make a clean user interface.

Key components
import snapshot
click location on an image => cell clicked
substack holding the formatted field, invisible
--there are other ways of doing invis fld

Hope this gets you started

Jim Ault
Las Vegas







More information about the use-livecode mailing list