Skip to content

Conversation

lizlooney
Copy link
Collaborator

@lizlooney lizlooney commented Oct 4, 2025

Changed mechanism, component, and event blocks to use functions mrcOnMove for handling events from blockly instead of the change framework.

Renamed mrcValidate to mrcOnModuleCurrent because it is called when the module becomes the current module.

Add warning if a component or mechanism block is moved out of the holder.

Update toolbox if mechanisms, components, or events are moved in to or out of the holder or deleted.

Fixes #232
Fixes #273

…if the block is not in the holder. Updated code in mrc_event.ts (which already existed) to be similar.
In mrc_mechanism_component_holder.ts:
Removed code that uses change framework.
Replaced function setName with method MechanismComponentHolderBlock.setNameOfChildBlock.
Replaced function updateToolboxAfterDelay with method MechanismComponentHolderBlock.updateToolboxAfterDelay.
Added function mrcDescenantsMayHaveChanged, which calls method MechanismComponentHolderBlock.mrcDescenantsMayHaveChanged.
MechanismComponentHolderBlock.mrcDescenantsMayHaveChanged collects the ids of mechanisms, components, private components, and events and if they have changed, calls updateToolboxAfterDelay.

Updated mrc_mechanism, mrc_component, and mrc_event to call MechanismComponentHolderBlock.setNameOfChildBlock when they are connected to the holder.

Update mrc_mechanism, mrc_component, and mrc_event to call mrcDescendantsMayHaveChanged when they are moved.
@lizlooney lizlooney requested a review from alan412 October 4, 2025 04:38
@lizlooney lizlooney marked this pull request as draft October 4, 2025 06:33
@lizlooney lizlooney marked this pull request as ready for review October 4, 2025 07:16
…aren't in

the holder. If there are more than one of these in a stack and the user drags
the whole stack out of the holder, the unplug will unplug the top one from the
stack which is alarming.

In mrc_mechanism_component_holder:
Changed mrcMechanismIds to mrcMechanismBlockIds,
mrcComponentIds to mrcComponentBlockIds,
mrcPrivateComponentIds to mrcPrivateComponentBlockIds, and
mrcEventIds to mrcEventBlockIds.
Made them strings, which makes the comparing much more simple.
Added mrcOnDescendantDisconnected, which is called when a mechanism, component,
or event block is deleted.

In editor, added code to handle move event for disconnect and call
mrcOnDescendantDisconnect on the root block that the block was disconnected
from.
@lizlooney lizlooney changed the title Changed most blocks to use functions mrcOnMove for handling events from blockly Changed mechanism, component, and event blocks to use functions mrcOnMove for handling events from blockly Oct 5, 2025
Copy link
Collaborator

@alan412 alan412 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, but it seems like we should also move mrc_param_container to use this way so that we can completely get rid of ChangeFramework. Made issue #274

@alan412 alan412 merged commit 06b177f into wpilibsuite:main Oct 5, 2025
1 check passed
@lizlooney lizlooney deleted the pr_blockly_events branch October 6, 2025 00:55
@lizlooney
Copy link
Collaborator Author

This looks great, but it seems like we should also move mrc_param_container to use this way so that we can completely get rid of ChangeFramework. Made issue #274

Agreed. I'm already working on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants