Table field behavior
Lynch, Jonathan
bnz2 at cdc.gov
Fri May 20 09:41:31 EDT 2005
I find the current table fields just too clunky.
I am creating a table object based on grouped fields. After a recent fix of a few bugs, it seems to work quite well, and allows for much better control.
The advantage to this approach is that it allowed me to do things like allow for a simple scheme for moving columns, inserting columns, proper tabbing, automatic vertical scrolling, etc...
If anyone wants a copy of this object, just e-mail me, and I will be happy to send it to you. It work well right now - but I plan to keep modifying it and adding in new capabilities.
For a table that needs to hold several hundred (or even several hundred thousand) rows, I am thinking of creating a different design - one that holds the data for each row in a custom property, and creates the fields/groups from the appropriate custom property for each row on the fly as the user scrolls up or down, then destroys those fields/groups as the row dissappears from view when it is scrolled past.
-----Original Message-----
From: use-revolution-bounces at lists.runrev.com [mailto:use-revolution-bounces at lists.runrev.com] On Behalf Of Bill
Sent: Friday, May 20, 2005 9:27 AM
To: How to use Revolution
Subject: Re: Table field behavior
Wow -- can't we make this any more complicated?
Thanks a whole lot. I will put your code in right now and start in as that
automatic scroll thing is annoying as ^(%$^%!@! (if you curse in unicode
than no one will see).
On 5/20/05 9:17 AM, "Eric Chatonet" <eric.chatonet at sosmartsoftware.com>
wrote:
> Hello Bill,
>
> I am working on a How-To stack about table fields.
> It's not finished but here is an excerpt from this stack which might
> help you without waiting for the release :-)
> As you will see it, it's a little bit dry and tricky :-(
> But fully commented :-)
> Following scripts are placed in the card script.
>
>> By default, a table has no limits: you can use the arrowkeys or the
>> tabkey to navigate as far as you wish.
>> Practically, you will often need to display a x*y cells table
>> without scrollbars as a matrix where all cells are visible and let
>> the user navigate in carousel (go from the last cell in a row to
>> the first cell in the next row and so on) through the limits you
>> have set.
>> In order to set these limits, you will trigger the keyboard events
>> within a rawKeyDown handler.
>> Here the limits which are integers are stored as custom properties
>> named xLimit and yLimit in the table field named "MyTable":
>>
>> on rawKeyDown pKey
>> -- allows tabbing and arrowkeys to act in carousel
>> -- horizontal and vertical limits are stored in 2 custom
>> properties (xLimit and yLimit) in the table field
>>
>> if "revCell" is in the target then
>> -- when editing a table field, target function returns
>> something like: field "revCell-1,1"
>> if the xLimit of fld "MyTable" = "None" or the xLimit of fld
>> "MyTable" is empty then pass rawKeyDown -- no limits
>> -----
>> switch pKey
>> case 65363 -- arrow key right
>> case 65289 -- tab key
>> if the cRevTable["currentxcell"] of fld "MyTable" = the
>> xLimit of fld "MyTable" then
>> if the cRevTable["currentycell"] of fld "MyTable" = the
>> yLimit of fld "MyTable" then
>> SelectCell "MyTable",1,1 -- the first table cell
>> else
>> SelectCell "MyTable",1,the cRevTable["currentycell"] of
>> fld "MyTable" + 1 -- the first table cell in the next line
>> end if
>> else pass rawKeyDown
>> break
>> -----
>> case 65361 -- arrow key left
>> if the cRevTable["currentxcell"] of fld "MyTable" = 1 then
>> if the cRevTable["currentycell"] of fld "MyTable" <> 1 then
>> SelectCell "MyTable",the xLimit of fld "MyTable",the
>> cRevTable["currentycell"] of fld "MyTable" - 1 --
>> -- the last allowed table cell in the previous line
>> else
>> SelectCell "MyTable",the xLimit of fld "MyTable",the
>> yLimit of fld "MyTable" --
>> -- the last allowed table cell
>> end if
>> else pass rawKeyDown
>> break
>> -----
>> case 65364 -- arrow key down
>> if the cRevTable["currentycell"] of fld "MyTable" = the
>> yLimit of fld "MyTable" then
>> if the cRevTable["currentxcell"] of fld "MyTable" = the
>> xLimit of fld "MyTable" then
>> SelectCell "MyTable",1,1 -- the first table cell
>> else SelectCell "MyTable",the cRevTable["currentxcell"] of
>> fld "MyTable" + 1,1 --
>> -- the first table cell in the next column
>> else pass rawKeyDown
>> break
>> -----
>> case 65362 -- arrow key up
>> if the cRevTable["currentycell"] of fld "MyTable" = 1 then
>> if the cRevTable["currentxcell"] of fld "MyTable" <> 1 then
>> SelectCell "MyTable",the cRevTable["currentxcell"] of fld
>> "MyTable" - 1,the yLimit of fld "MyTable" --
>> -- the last allowed table cell in the previous column
>> else SelectCell "MyTable",the xLimit of fld "MyTable",the
>> yLimit of fld "MyTable" --
>> -- the last allowed table cell
>> else pass rawKeyDown
>> break
>> -----
>> default
>> pass rawKeyDown -- lets the engine do it
>> end switch
>> else pass rawKeyDown
>> end rawKeyDown
>> ----------------------------------------------------------------
>>
>> on SelectCell pFieldName,pColumn,pRow
>> -- select a cell
>>
>> -- pFieldName parameter is the short name of the table field
>> -- pColumn parameter is the column number (an integer)
>> -- pRow parameter is the row number (an integer)
>>
>> SetCurXCell pFieldName,pColumn --
>> SetCurYCell pFieldName,pRow --
>> -----
>> SetScroll "hScroll",the cRevTable["cellxspacing"] of fld
>> pFieldName * (pColumn - 1),pFieldName,"Header" --
>> SetScroll "vScroll",the cRevTable["cellyspacing"] of fld
>> pFieldName * (pRow - 1),pFieldName,"Rows" --
>> -----
>> click at CellLoc(pFieldName,pColumn,pRow) --
>> -----
>> -- to select again the current cell, you can use:
>> -- click at the cRevTable["currentxmouseloc"] of fld
>> pFieldName,the cRevTable["currentymouseloc"] of fld pFieldName
>> end SelectCell
>>
>> ----------------------------------------------------------------
>>
>> function CellLoc pFieldName,pColumn,pRow
>> -- returns the loc of any cell
>>
>> -- pFieldName parameter is the short name of the table field
>> -- pColumn parameter is the column number (an integer)
>> -- pRow parameter is the row number (an integer)
>>
>> local
>> tLeft,tTop,tCellxspacing,tCellyspacing,tCurrenthscroll,tCurrentvscroll
>> -----
>> put the left of fld pFieldName into tLeft
>> put the top of fld pFieldName into tTop
>> put the cRevTable["cellxspacing"] of fld pFieldName into
>> tCellxspacing
>> put the cRevTable["cellyspacing"] of fld pFieldName into
>> tCellyspacing
>> put the hScroll of fld pFieldName into tCurrenthscroll
>> put the vScroll of fld pFieldName into tCurrentvscroll
>> return ((pColumn - 1) * tCellxspacing) + (tCellxspacing div 2) +
>> tLeft - tCurrenthscroll, \
>> ((pRow - 1) * tCellyspacing) + (tCellyspacing div 2) + tTop -
>> tCurrentvscroll
>> end CellLoc
>> ----------------------------------------------------------------
>>
>> on SetCurXCell pFieldName,pValue
>> -- updates prop in the cRevTable of the table field
>>
>> -- pFieldName parameter is the short name of the table field
>> -- pValue parameter is the column number (an integer)
>>
>> set the cRevTable["currentxcell"] of fld pFieldName to pValue
>> end SetCurXCell
>>
>> ----------------------------------------------------------------
>>
>> on SetCurYCell pFieldName,pValue
>> -- updates prop in the cRevTable of the table field
>>
>> -- pFieldName parameter is the short name of the table field
>> -- pValue parameter is the row number (an integer)
>>
>> set the cRevTable["currentycell"] of fld pFieldName to pValue
>> end SetCurYCell
>>
>> ----------------------------------------------------------------
>>
>> on SetScroll
>> -- sets the table field and header fields scrolls if they are any
>> -- the syntax is not very comprehensible since this handler can
>> set the scroll of an unknown number of fields
>> -- then it refers to parameters by order/number and not by name
>> using the do command
>>
>> lock screen
>> lock messages
>> repeat with i = 3 to the paramcount
>> do "put there is a fld" && param(i) && "into tFlag"
>> if tFlag then do "set the" && param(1) && "of fld" && param(i)
>> && "to" && param(2)
>> -- param (3) to param(x) are the names of the fields
>> end repeat
>> unlock messages
>> unlock screen
>> end SetScroll
>
> That's all!
> Is it enough?
> LOL
>
> Le 20 mai 05 à 14:58, Bill a écrit :
>
>> The docs on table fields is rather sparse.
>>
>> An example table field has six cells across. It is unlocked on Mac
>> OSX. When
>> you enter data and tab across to the next cell and enter data for
>> that cell
>> and tab it works fine until you get to the last cell then it
>> automatically
>> scrolls to the right (there are no scroll bars set for either
>> vertical or
>> horizontal). This automatic scroll to the right makes all the
>> previously
>> entered data not visible and is a behavior I want to prevent. I tried
>> locking position and that didn't work.
>>
>> How do I do this?
>
>
> Best regards from Paris,
>
> Eric Chatonet.
> ----------------------------------------------------------------
> So Smart Software
>
> For institutions, companies and associations
> Built-to-order applications: management, multimedia, internet, etc.
> Windows, Mac OS and Linux... With the French touch
>
> Plugins, tutorials and more on our website
> ----------------------------------------------------------------
> Web site http://www.sosmartsoftware.com/
> Email eric.chatonet at sosmartsoftware.com/
> Phone 33 (0)1 43 31 77 62
> Mobile 33 (0)6 20 74 50 86
> ----------------------------------------------------------------
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
| | |
)_) )_) )_)
)___))___))___)\
)____)____)_____)\\
_____|____|____|____\\\__
-------\ /--------- http://www.bluewatermaritime.com
^^^^^ ^^^^^^^^^^^^^^^^^^^^^
^^^^ ^^^^ ^^^ ^^
^^^^ ^^^
24 hour cell: (787) 378-6190
fax: (787) 809-8426
Blue Water Maritime
P.O. Box 91
Puerto Real, PR 00740
_______________________________________________
use-revolution mailing list
use-revolution at lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list