CustomSegue icon indicating copy to clipboard operation
CustomSegue copied to clipboard

View controllers below the current view controller are receiving click events

Open ivanmkc opened this issue 9 years ago • 1 comments

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

ivanmkc avatar Oct 21 '16 20:10 ivanmkc

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
    }
}

phimage avatar Oct 21 '16 21:10 phimage