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 the ability to make a read-only workspace writable #3049

Closed
NoahAndrews opened this issue Sep 19, 2019 · 5 comments
Closed

Add the ability to make a read-only workspace writable #3049

NoahAndrews opened this issue Sep 19, 2019 · 5 comments
Labels
Milestone

Comments

@NoahAndrews
Copy link

Is your feature request related to a problem? Please describe.

I need to be able to have a workspace start out as read-only, but become writable.

Describe the solution you'd like

For maximum flexibility, I'd love to see a workspace.setReadOnly(boolean) function, but if it's easier to only support going from read-only to writable, a function workspace.enableEditing() would suffice.

Describe alternatives you've considered

I found this message from Neil on Google Groups, which suggests putting a transparent div over Blockly to prevent interactions. The problem with this is that it also disables panning and zooming around the Blockly workspace. I want users to be able to interact with, but not edit, the workspace.

Additional context

In that message, Neil said this:

Readonly cannot be changed after init. There are too many event handlers that would need to be added and removed.

I don't understand why that would be an unsolvable problem (maybe I'm just not familiar enough with the Blockly source). I'd like to try to implement this change myself, so I'd appreciate any additional context or guidance that anyone (@NeilFraser) can give me.

@NoahAndrews NoahAndrews added issue: triage Issues awaiting triage by a Blockly team member issue: feature request Describes a new feature and why it should be added labels Sep 19, 2019
@RoboErikG RoboErikG added component: developer apis component: multiworkspace and removed issue: triage Issues awaiting triage by a Blockly team member labels Sep 19, 2019
@RoboErikG
Copy link
Contributor

It's a lot of work to implement correctly and to maintain. It's also not a common use case, so it's unlikely to get prioritized by us anytime soon. You're welcome to give it a shot, though.

@RoboErikG RoboErikG added this to the Icebox milestone Sep 19, 2019
@BeksOmega
Copy link
Collaborator

You might also be able to handle this by:

  1. Serializing the readonly workspace.
  2. Disposing of it.
  3. Re-injecting an editable workspace.
  4. Deserializing.

I've done this for language-changing before and I remember it being pretty seamless.

@NoahAndrews
Copy link
Author

@BeksOmega How do I properly dispose of a workspace? I basically tried what you suggested, and couldn't get it to work correctly. I think the new workspace still wasn't really editable.

@NoahAndrews
Copy link
Author

NoahAndrews commented Sep 20, 2019

Oh there's an actual dispose method! Nice! I'll have to try that out, thank you.

@NoahAndrews
Copy link
Author

NoahAndrews commented Sep 25, 2019

@BeksOmega Thanks so much, it's working great now! This can be closed if desired.

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

No branches or pull requests

4 participants