Hello,
my nodes look like this:
------------
| Title |
| items[0] |
| sub[a] |
| sub[b] |
| items[1] |
| sub[a] |
------------
The title, and each of the variable number of items and subs, is made up of an editable TextBlock
. Depending on which kind of TextBlock
is edited, I want different consequences.
When the Title is modified, I want a call titleModified(nodeKey)
.to happen.
When an item is modified, I want a call to itemModified(nodeKey,itemKey)
.
When a sub is modified, I want a call to subModified(nodeKey,itemKey,subKey)
.
(I know how to find subKey
and itemKey
given the part
in which the TextBlock
that was edited sits.)
How can I easily detect whether a title
, item
, or sub TextBlock
was modified, using a listener?
I didn’t find a textEdited
property for the TextBlock
where I can assign an event handler. Is there one?
The TextBlocks
all use .makeTwoWay()
, so I could set a different backConverter
for each. But this is ruled out by the documentation:
Conversion functions must not have any side-effects other than setting the source property.
I am currently using the textEdited
listener on the diagram, but it’s hard to evaluate what kind of textblock the event came from. If I could assign category:"title"
, category:"item"
or category:"sub"
to my TextBlock
, the problem would be solved, but I cannot see such a possibility.
If it’s possible to do this using a ChangedEvent
(presumably using a modelChange
of type nodeDataArray
), what is the pattern for doing so? This is my least-preferred solution, since I find filtering through hundreds of changes in the transaction until I’ve found the right one unintuitive – and the functions titleModified itemModified subModified
make further changes to the model, so I have to queue the changes to happen after identifying those necessary changes in a transaction.changes.each
call; I only know how to organise this in awkward ways.