Datagrid SelectionChanged issues

David Bovill david.bovill at gmail.com
Thu Aug 27 16:51:31 EDT 2009


2009/8/27 Trevor DeVore <lists at mangomultimedia.com>

> On Aug 27, 2009, at 10:26 AM, David Bovill wrote:
>
> Shows that when using  "set the dgHilitedLine" both params to
> "selectionChanged" are empty, and "the dgHilitedLine" is set
> inconsistently?
>
> David,
>
> Setting the dgHilitedLine doesn't send selectionChanged (behavior mimics
> that of list fields). I just pasted your selectionChanged handler into a new
> data grid and tested your FindLine code to confirm. Did you override
> dgHilitedLine or are you firing off a selectionChanged message from
> somewhere else in your code?


Not firing off a selectionChanged message. I do have my own "setprop
dgHilite pBoolean" handler, but that only sets the backgroundcolour of a
group... ah think I've got it - its not the datagrid that is firing - it is
the list field? That is the list field is being used to "set the
dgHilitedLine of grp..." and in doing so the selection is being lost from
the field and moved to the datagrid. Explains why the params are empty - but
not why the dgHilitedLine reports an old value.

Figured it:

on selectionChanged pHilitedIndex, pPrevHilitedIndex
>    if pHilitedIndex is empty then
>       beep
>       put the dgHilitedLine of grp "Datagrid" into vLineNum
>       answer ("Selection changed using dgHilitedLine!" && vLineNum && "is
> the old dgHilitedLine, as the message is sent before the datagrid is set.")
>    else
>       put the dgHilitedLine of grp "Datagrid" into vLineNum
>       answer ("This works correctly" && vLineNum && "is the new (not old)
> dgHilitedLine.")
>    end if
> end selectionChanged


What is happening is that in the case of the list field triggering the
datagrid the message is sent of BEFORE the datagrid is set, while in the
case of clicking on the datagrid it is being sent AFTER the datagrid is set.
This is as expected I guess if not a bit confusing - personally I think i
would have prefered a datagrid specific message being sent - easier to trap
and distinguish between messages from differnet controls. Anyway problem
solved :)



More information about the use-livecode mailing list