In a MultiArgMorph showing an arbitrary list of upvars or strings:
When you use the < and > buttons to add and remove slots, an update event is fired so the surrounding context can react.
When you use the right-click menus to delete and insert slots, no update event is fired.
Reproduction steps
Define a language with a block that has an input of type %mult%upvar or %mult%s
Add an update event handler to the top-level IDE_Morph
Drag in an instance of the block and create multiple values:
Delete the last one by using the < button
Notice that the update event handler fires
Delete the next-to-last one by opening the context menu and clicking "delete variable"
Notice that the UI updates as before, but not update event is fired.
Research notes
A similar issue also happens for adding a new item to the multi-arg block, where if you use the > arrow, an update is emitted, but if you right-click and select "insert a variable", it is added in the UI but not update event is emitted.
The issue seems to happen whether the embedded item is an upvar (as it was in my initial testing) or a plain string slot, as I've since tested with.
How to fix
I tried debugging through this to understand why the event gets thrown in one case and not another, but can't quite find it. I think it might just be a side-effect of the first case deleting and re-creating the FrameMorph wrapping the arrows.
There are some code comment notes about a deliberate difference between remove and delete, so I wanted to ask before making arbitrary changes.
Tracing through what happens yielded:
When you click the < button at the end of the list to remove the last item...
This is handled by MultiArgMorph#removeInput
Which then triggers a removeChild on both a TemplateSlotMorph and a FrameMorph
It also triggers an update event so we can re-run code generation to take account of the removed item.
When you right-click and delete the last item in the list
This is handled by MultiArgMorph#deleteSlot
Which only calls removeChild for the TemplateSlotMorph and not the FrameMorph
It does not trigger an update event, so the surrounding context can't update because of the removed item.
Thanks, Adam, good catch! This is going to be a quick and easy fix, I think. I'm all busy and traveling this week, but hope to get around to fixing it either over the weekend or early next week.
In a MultiArgMorph showing an arbitrary list of upvars or strings:
<
and>
buttons to add and remove slots, anupdate
event is fired so the surrounding context can react.update
event is fired.Reproduction steps
%mult%upvar
or%mult%s
update
event handler to the top-levelIDE_Morph
<
buttonupdate
event handler firesupdate
event is fired.Research notes
>
arrow, anupdate
is emitted, but if you right-click and select "insert a variable", it is added in the UI but notupdate
event is emitted.How to fix
I tried debugging through this to understand why the event gets thrown in one case and not another, but can't quite find it. I think it might just be a side-effect of the first case deleting and re-creating the
FrameMorph
wrapping the arrows.There are some code comment notes about a deliberate difference between remove and delete, so I wanted to ask before making arbitrary changes.
Tracing through what happens yielded:
When you click the
<
button at the end of the list to remove the last item...MultiArgMorph#removeInput
removeChild
on both aTemplateSlotMorph
and aFrameMorph
update
event so we can re-run code generation to take account of the removed item.When you right-click and delete the last item in the list
MultiArgMorph#deleteSlot
removeChild
for theTemplateSlotMorph
and not theFrameMorph
update
event, so the surrounding context can't update because of the removed item.