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

View controllers below the current view controller are receiving click events #3

Open
ivanmkc opened this issue Oct 21, 2016 · 1 comment

Comments

@ivanmkc
Copy link

ivanmkc commented Oct 21, 2016

Hi,

When I click a cell on my table view controller, it opens up a new screen using your a SlideLeftSegue. However on this new screen, when I click an empty spot, the cells underneath it receive the click and segues again.

Why does the screen below still get click events and how do I prevent this?

Many thanks,
Ivan

@phimage
Copy link
Owner

phimage commented Oct 21, 2016

I am not very confident to handle this in all situations
so I make a bool removeFromView
When configuring the segue

class MyViewController: NSViewController {

  override func prepareForSegue(segue: NSStoryboardSegue, sender: AnyObject?)
      if segue.identifier == "myseguename" {
          if let segue = segue as? PresentWithAnimatorSegue, animator = segue.animator as? TransitionAnimator {
              animator.removeFromView = true
          }
      }
  }

This will remove temporary the source controller from the view hierarchy (by replacing it with an empty view)

Sometimes in my code I override some view functions to stop mouse event to propagate

class MyView: NSView {
    override func mouseDown(theEvent: NSEvent) {
      // pass event only to wanted element, call preventDefault etc...
    }
    override func acceptsFirstMouse(theEvent: NSEvent?) -> Bool {
        return true
    }
}

DimaRU pushed a commit to DimaRU/CustomSegue that referenced this issue May 1, 2017
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

No branches or pull requests

2 participants