How to tell when a datagrid column has been resized
Bob Sneidar
bobs at twft.com
Fri Dec 23 11:42:06 EST 2011
Thanks Pete. I figured out a way to do it by intercepting getProp dgColumnWidth. I was hoping to tell when a column had been resized after the fact, but I do not think a message gets sent. Things only happen during the resize operation. That will have to do.
I store a property of column properties, the name, the label and the width as a tab delimited list. Then I use this script in the datagrid:
getprop dgColumnWidth [pColumn]
put the tblDisplay of this card into theColumnData
put the dgProp["column widths"] of me into theColumnWidths
replace comma with tab in theColumnWidths
put the itemdelimiter into theOldDelim
set the itemdelimiter to tab
repeat with theCount = 1 to the number of lines of theColumnData
put item theCount of theColumnWidths into item 3 of line theCount of theColumnData
end repeat
set the tblDisplay of this card to theColumnData
set the itemdelimiter to theOldDelim
pass dgColumnWidth
end dgColumnWidth
Works a treat.
Bob
On Dec 22, 2011, at 5:36 PM, Pete wrote:
> There's a mouseUp handler in the default header behavior script for a
> datagrid that looks like this:
>
> *on* mouseUp pMouseBtnNum
>
> *if* pMouseBtnNum is 1 and not the dgHeaderColumnIsBeingResized of
> thedgHeader
> of me *then*
>
> *## Change the sort of the column*
>
> *## _HeaderToggleSortOfColumn is a helper that resizes in the parent
> group script.*
>
> *## It toggles the sort of the column based on current state of
> column.*
>
> _HeaderToggleSortOfColumn the dgColumn of me
>
> *end* *if*
>
> *pass* mouseUp
>
> *end* mouseUp
>
>
> You might be able to figure something out from that. For example , set the
> default header behavior script to your own copy of it and then if
> the dgHeaderColumnIsBeingResized property is true, do whatever it is you
> need to do.
>
>
> Pete
>
> On Thu, Dec 22, 2011 at 5:11 PM, Bob Sneidar <bobs at twft.com> wrote:
>
>>> Hi all. I have read up on all the lessons that might help, as well as
>> searched the datagrid library, and I cannot find anyplace where a message
>> gets sent when a column has been resized. I would like to trap that message
>> so the next time around I can set up the datagrid the way it was last. Any
>> ideas?
>>>
>>> Bob
>>>
>>>
>> Never mind. I figured out a way. I just put a handler for getprop
>> dgColumnWidth [pColumn] in the script of the datagrid and then pass it when
>> through. I think I was hoping for some kind of message to get sent when the
>> resize was FINISHED. This gets sent when a column resize is in progress,
>> even if the column is not changing in size at the time. As long as the
>> mouse is down on the column divider, it keeps triggering. It feels dirty
>> somehow, like I ought to be trying to be more efficient, and can't be.
>>
>> Oh well. I have CPU cycles to spare I guess...
>>
>> Bob
>>
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>>
>
>
> --
> Pete
> Molly's Revenge <http://www.mollysrevenge.com>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list