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

Populate undo stack when loading a drawing? #37

Open
junsolOh opened this issue Mar 20, 2020 · 3 comments
Open

Populate undo stack when loading a drawing? #37

junsolOh opened this issue Mar 20, 2020 · 3 comments

Comments

@junsolOh
Copy link

In the demo, I tried to undo after reload. But undo doesn't work. What is the reason?

@stevelandeyasana
Copy link
Collaborator

The reason is there's a bug. :-) Unfortunately it's unlikely I'll have time to fix it.

@stevelandeyasana stevelandeyasana added the bug Something isn't working label Apr 3, 2020
@stevelandeyasana
Copy link
Collaborator

Oh, I think I understand better now. This might not actually be a bug.

The 'reload' feature is meant to test serialization. When you load a drawing, the user hasn't taken any action yet, so there's nothing to undo.

Unmarking this as a bug and retitling to capture the issue more clearly. I'm not sure we actually want to change this.

@stevelandeyasana stevelandeyasana removed the bug Something isn't working label Apr 22, 2020
@stevelandeyasana stevelandeyasana changed the title Undo is not working after reload Populate undo stack when loading a drawing? Apr 22, 2020
@ysvganesh
Copy link

ysvganesh commented Sep 29, 2020

It's working when I reassign operationStack delegate & buttons actions

  ......
  drawingView.drawing = try! JSONDecoder().decode(Drawing.self, from: drawingData)

  drawingView.operationStack.delegate = self
      
  undoButton.addTarget(drawingView.operationStack, action: #selector(DrawingOperationStack.undo), for: .touchUpInside)
  redoButton.addTarget(drawingView.operationStack, action: #selector(DrawingOperationStack.redo), for: .touchUpInside)

Reason to failed undo stack after reload

public var drawing: Drawing = Drawing(size: CGSize(width: 320, height: 320)) {
    didSet {
      tool?.deactivate(context: self.toolOperationContext)
      operationStack = DrawingOperationStack(drawing: drawing) // New Object will assign
     .........
  }

Hope this will help.

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

No branches or pull requests

3 participants