Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add copy / paste scripts #3286

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

ego-lay-atman-bay
Copy link
Contributor

@ego-lay-atman-bay ego-lay-atman-bay commented Dec 9, 2023

This is pretty much the same as my other pull request, but this time it's to the dev branch instead of master, and this time I didn't merge master into it (meaning the only files that were changed are the files I changed (I hope I did it right this time)).

This adds the ability to copy / paste scripts and comments. It works by setting a value to the block xml, which it then loads as if the user dropped a file into the script area. This makes sure that blocks are properly pasted, so if a custom block that doesn't exist in that scene or sprite, it creates the custom block. The only issue with this implementation is that when a user copies a custom block, then changes the custom block and then pastes, the custom block will be replaced by the old definition.

If you right click a block, there will be 3 new options:

  • copy below
    • Copy this block and below
  • copy block
    • Copy this block only
  • cut block
    • Copy this block, and delete it.

Comments also have new options

  • copy comment
    • Copy this comment
  • cut comment
    • Cut this comment

When you copy a comment, the width is also copies, so when you paste it, it stays the same width.

When you right click the editor area, there is a new option to paste (it only shows if you have already copied something).

There are also some keyboard shortcuts

  • ctrl + c - copy all underneath mouse, or if it's a comment, just copy the comment.
  • ctrl + shift + c - copy only this block or comment underneath mouse.
  • ctrl + x - cut block or comment underneath the mouse.
  • ctrl + v - paste whatever is in the clipboard.

I know this would make editing faster, because you don't have to drag blocks a very long distance now. You can just cut the script, then scroll to where you need the script, and paste (and it helps with accidentally dropping it in a c slot while dragging it up or down).

Again, the only issue with this is that when you copy a custom block, edit it, then paste, the definition will revert back to when you copied the block. I don't know of an elegant way of fixing this, as it would require modifying the IDE_Morph.prototype.droppedText function.

I am open to talking about this, and modifications. I don't think it would be best to merge this as it is currently, because I'm not sure if the function names should be renamed.

@ego-lay-atman-bay
Copy link
Contributor Author

I guess this should continue the discussion at #3280.

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.

1 participant