REVO2700 OldTableFieldDragDividers @ ^ P7 4 U Lucida Grande U Lucida Grande U Verdana U Verdana W Verdana W Lucida Grande cRevOnline id 428 cREVGeometryCache stackID 1749 cREVGeneral breakpointconditions revUniqueID 1263238300481breakpoints breakpointstates stackfileversion 2.7 P 0on opencard choose browse tool end opencard 7 tRevGeneral tRevUniqueID 1263139563611 cREVGeneral scripteditorvscroll 0revUniqueID 1263139562609scripteditorselection 33 cREVGeometryCacheIDs 1263071257819 10031266331847246 17111263071352529 10111263071975760 10281263071267507 10061263071298912 10101266332259237 17491263071292462 10071263071821393 10261263072425933 1030 cREVGeometrycache total 10order cREVTable acell false TField )s'n -- > This trys to teach the table field object some tricks -- just take a standard field, if it's vgrid (in the table properties) is set to true then this will work -- of course you can also use a standard table field with it's revCell editing true or false -- the field has to be locked for this to work -- a backdoor is to hold the option and command key (alt + command key on windows) down when entering the field -- this will set the locktext to true, to end the locktext leave the field and enter it again without modifier keys -- over column dividers the cursor will change and you can change its size by click dragging (min width 3 pixel) -- if you are over the leftmost divider (the first from left) and press the option key (or alt key) you change the width of all dividers at once -- if you press the control key and click anywhere in the field, the dividers will adjust to the width of the -- text in the columns with 20 pixel min width and 150 pixel max width, adjustable in the script. -- you can put this script into a behavior button and assign that button to any number of fields -- or you paste this script into your field. -- sometimes a simple tablefield can be usefull and it is less complicated then a datagrid or a listmagic field, for anything more involved -- of course those are much more powerful. -- if you find quirks you will find me on the list or in the forum -- Feb 2010 Bernd Niggemann local sMouseWasPressed local sStoppsArray, sWhich, sAbsMouseHorizontal local sOriginalWidthOfColumn local sAbsColumnLocs, sHScroll local sIAmLocked, sIWasLocked on mouseEnter --> if a field is unlocked then you can lock it -- temporarily, change divider columns and -- by leaving the field and going back into it -- the field will be unlocked if the commandKey is down and the optionKey is down then put the lockText of me into sIWasLocked set the lockText of me to true end if --> only work on locked fields put the lockText of me into sIAmLocked if not sIAMLocked then exit mouseEnter put the width of me into tWidthOfField put the formattedWidth of me into tFormatWidth --> when field is empty with 1 tabstop defined the formattedWidth is -- smaller then the width of the field if tWidthOfField > tFormatWidth then put tWidthOfField into tFormatWidth -- set the horizontal scrollbar if : if tWidthOfField < tFormatWidth then set the hScrollbar of me to true put the left of me into tLeft put the tabStops of me into tStopps -- if it is a plain locked field if tStopps is "" then exit mouseEnter put last item of tStopps into tLastColumnLoc put the number of items of tStopps into tColumnCounter if the number of items of tStopps > 1 then put tLastColumnLoc - (item -2 of tStopps) into tLastColumnWidth else put tLastColumnLoc into tLastColumnWidth end if --> make an array of all the widths of the columns -- by subtracting the previous loc(s) to get the widths put 0 into tPrevPixels put "" into sStoppsArray repeat with i = 1 to tColumnCounter put item i of tStopps - tPrevPixels into sStoppsArray[i] add item i of tStopps - tPrevPixels to tPrevPixels end repeat -- since the tabstops of a field dont necessarily mark all the visible column dividers --> we fill up the tabstops for all dividers -- if not all tabstops are marked table field uses the width of the last tabstop to mark the rest -- hence we use the width of the last column to fill up the tabstops -- and we fill up the array here to reflect all dividers if tLastColumnLoc < tFormatWidth then repeat with i = tLastColumnLoc to tFormatWidth step tLastColumnWidth add 1 to tColumnCounter put tLastColumnWidth into sStoppsArray[tColumnCounter] end repeat end if --> make a list of the absolute pixel locations for the dividers -- so we can test for them in the mouseMove handler to indicate divider add 2 to tLeft -- seems necessary because of 2 pixels needed for field hilite put "" into sAbsColumnLocs repeat with i = 1 to tColumnCounter add sStoppsArray[i] to tLeft put tLeft & comma after sAbsColumnLocs end repeat delete last char of sAbsColumnLocs -- a comma end mouseEnter on mouseLeave -- restore unlocked state if field was unlocked on mouseEnter if sIWasLocked is false then set the lockText of me to sIWasLocked end if -- just to make shure unlock cursor end mouseLeave on mousemove x,y --> get out if field is not locked if not sIAMLocked then exit mouseMove if not sMouseWasPressed then -- the part to detect dividers and change the cursor -- add the hscroll in case the horizontal scrollbar is active if the hScrollbar of me then add the hScroll of me to x if x is among the items of sAbsColumnLocs then set the cursor to 31 lock cursor else unlock cursor end if -- mouse Was Pressed else --> here we change the width of the column add sHScroll to x -- take the horizontal scroll into account, was set in mouseDown put sAbsMouseHorizontal - x into tdiff -- set the new width of the column we are in put sOriginalWidthOfColumn - tDiff into tNewWidth -- lets not get smaller then 3 pixel if tNewWidth < 4 then put 3 into tNewWidth beep end if --> if the optionKey is down over first column divider -- change all collumdivders to the size of the first column if sWhich = 1 and the optionKey is down then put tNewWidth into tTabsCollector set the tabStops of me to tTabsCollector exit mouseMove end if put tNewWidth into sStoppsArray[sWhich] put the keys of sStoppsArray into tStoppsKey sort tStoppskey numeric ascending put 0 into tWidthCounter --> make a new tabstops list by adding the previous tabstops -- to the actual width to change just one column repeat for each line aLine in tStoppskey put (tWidthCounter + sStoppsArray[aLIne] & ",") after tTabsCollector add sStoppsArray[aLIne] to tWidthCounter end repeat delete last char of tTabsCollector -- a comma set the tabStops of me to tTabsCollector end if -- mouse was pressed end mousemove on mouseDown --> set the width of the columns to the widths of the content -- by pressing the controlkey and clicking if the controlKey is down then adjustToWidthOfContent exit mouseDown end if -- we are not over a column divider so we exit the mouseDown message if not the lockCursor then exit mouseDown put true into sMouseWasPressed select empty put the clickLoc into tWhere put item 1 of tWhere into sAbsMouseHorizontal if the hScrollbar of me then put the hScroll of me into sHScroll else put 0 into sHScroll end if add sHScroll to sAbsMouseHorizontal repeat with i = 1 to the number of items of sAbsColumnLocs -- filled on mouseEnter if sAbsMouseHorizontal = item i of sAbsColumnLocs then exit repeat end repeat put i into sWhich -- we got the number of the collumn divider put sStoppsArray[sWhich] into sOriginalWidthOfColumn end mouseDown on mouseUp if sMouseWasPressed then put false into sMouseWasPressed unlock cursor if the hScrollbar of me then set the hScroll of me to sHScroll focus me select empty send mouseEnter to me -- because when changing dividers it refreshes list of colums else send mouseEnter to me -- because when moving vertical scrollbar, refreshes list of colums end if end mouseUp on mouseRelease send mouseUp to me end mouseRelease on adjustToWidthOfContent --> if plain field exit if the tabStops of me = "" then exit adjustToWidthOfContent -- unselect a currently focused cell if the short name of the focusedObject contains "revcell" then select empty set the itemDelimiter to tab put me into tData put 0 into tItemCounter repeat for each line aLine in tData put the number of items of aLIne into tCount if tCount > tItemCounter then put tCount into tItemCounter end repeat put "" into tColumnWidth --> get the formattedwidth for each item and put it into a list of the widths repeat with i = 1 to the number of lines of me repeat with j = 1 to tItemCounter put the formattedWidth of item j of line i of me +10 into tFormatteWidthOfItem -- 10 are added for margin if tFormatteWidthOfItem > item j of tColumnWidth then put tFormatteWidthOfItem into item j of tColumnWidth end repeat end repeat --> adjust the min and max width of the list of widths here put 150 into tMaxWidth -- set maximum width here put 20 into tMinWidth -- set minimum width here repeat with k = 1 to tItemCounter put (min(tMaxWidth,max(item k of tColumnWidth,tMinWidth))) into item k of tColumnWidth end repeat -- make a list for the tabstops in the format of added widths put 0 into tPixelCounter repeat with m = 1 to the number of items of tColumnWidth put item m of tColumnWidth + tPixelCounter into item m of tNewTabStops add item m of tColumnWidth to tPixelCounter end repeat -- catch for empty field, no text at all in it if tItemCounter = 0 then put tMinWidth into tNewTabStops else put tab & tMinWidth after tNewTabStops -- so the non-text containing cells are at minimum width end if --breakpoint replace tab with "," in tNewTabStops -- make the items comma delimited set the tabStops of me to tNewTabStops if the formattedWidth of me > the width of me then set the hScrollbar of me to true else set the hScrollbar of me to false end if click at -1,-1 -- to unselect a RevCell end adjustToWidthOfContent X n2 . E \ "9Pg~6Md{ tRevGeneral tRevUniqueID 1263071258822 cREVTable topcellloc 251leftcellloc 183formattedview
1 200 30000 text more than 150 pixels wide not a text
100 2 30 text less than 150 pixls just some text
345 6789 123
some more text
currentxmouseloc 205currenthscroll 0bottomcellloc 272currentymouseloc 262 rightcellloc 243scrollbarwidth 16 cellyspacing 14rightfieldloc 650topfieldloc 110 leftfieldloc 88maxColumnCount 5 cellxspacing 23currentview
1 200 30000 text more than 150 pixels wide not a text
100 2 30 text less than 150 pixls just some text
345 6789 123
some more text
currentvscroll 0 viewablerows 17 currentxcell 5 currentycell 11currentcellvalue viewablecolumns 23cellformat falsenumbertabstops 26 celledit truebottomfieldloc 342 cREVGeneral table truerevUniqueID 1263071257819scripteditorvscroll 3099scripteditorselection 7947 61 200 30000 text more than 150 pixels wide not a text 1100 2 30 text less than 150 pixls just some text 345 6789 123 some more text ` y o A a YE! Button ep ]on mouseUp send "adjustToWidthOfContent" to field "TField" in 2 milliseconds end mouseUp @sets the width of the columns to the formattedWidth of the text 0 adjustToWidthOfContent tRevGeneral tRevUniqueID 1263071268513 cREVGeneral revUniqueID 1263071267507scripteditorvscroll 0scripteditorselection 39 Button ep Fon mouseUp set the tabstops of field "TField" to "30" end mouseUp 2 p set test columns 0 widthAll 30 tRevGeneral tRevUniqueID 1262464559352 cREVGeneral scripteditorvscroll 0revUniqueID 1263071292462scripteditorselection 48 Button ep Von mouseUp set the tabstops of field "TField" to "30,30,30,40,40,140" end mouseUp set test columns 4 width 30,30,30,40,40,140 tRevGeneral tRevUniqueID 1262464559352 cREVGeneral revUniqueID 1263071298912scripteditorvscroll 0scripteditorselection 65 Field ` l cREVGeneral revUniqueID 1263071821393 @sets the width of the columns to the formattedWidth of the text Rectangle K@ ` > cREVGeneral revUniqueID 1263071975760 Field ` [ cREVGeneral revUniqueID 1263072425933 Test tabstops fHelp ` P . kon mouseUp set the visible of me to not the visible of me end mouseUp <