Skip to content

Conversation

@lizlooney
Copy link
Collaborator

Make copy/paste work between tabs.

Fixes #230

Fixes #317

Added code in onChangeAfterLoading to handle VIEWPORT_CHANGE and BLOCK_CREATE events.
For VIEWPORT_CHANGE, set the paste location to the center of the blockly workspace.
For BLOCK_CREATE, call mrcOnCreate on the newly created block (if the block has that method).
In makeCurrent, set the paste workspace and location.

In mrc_call_python_function.ts, mrc_component.ts, mrc_event.ts, mrc_event_handler.ts, mrc_mechanism.ts:
Added mrcOnCreate so blocks that are created or pasted are checked.

In mrc_call_python_function.ts, mrc_event_handler.ts, mrc_jump_to_step.ts, mrc_mechanism.ts:
Check whether getIcon(Blockly.icons.IconType.WARNING) returns null.

In mrc_call_python_function.ts:
Added code to checkFunction to check blocks that call an instance method defined in the same module.
@lizlooney lizlooney requested a review from alan412 November 17, 2025 06:47
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.

In general I really like this, but I found a minor bug. If you copy something that isn't allowed to be copied (say a built-in method or the opmode block) there is no user indication and if you then paste it pastes what was copied before.

I think it should tell you that you can't copy that and also clear the clipboard.

@lizlooney
Copy link
Collaborator Author

In general I really like this, but I found a minor bug. If you copy something that isn't allowed to be copied (say a built-in method or the opmode block) there is no user indication and if you then paste it pastes what was copied before.

I think it should tell you that you can't copy that and also clear the clipboard.

Is that minor bug introduced in this PR? Or, is that minor bug present in the main branch?

@alan412
Copy link
Collaborator

alan412 commented Nov 18, 2025

Steps to reproduce:

  1. Put a comment in a method. Copy and paste it somewhere. Works as expected.
  2. Select the init method in robot. Press Ctrl-C.
  3. Change to Teleop. Press Ctrl-V. Comment from step 1 is pasted.

I debated whether to accept this PR and just file it as a separate issue. I could go either way.

@lizlooney
Copy link
Collaborator Author

I'd prefer to handle that bug in a separate PR.

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.

Put bug in as #320

@alan412 alan412 merged commit 66ed284 into wpilibsuite:main Nov 20, 2025
1 check passed
@lizlooney lizlooney deleted the pr_issue_230_copy_paste branch November 21, 2025 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Block that calls a method defined in the same module isn't updated after copy, rename, paste Copy/Paste should work between tabs

2 participants