Loading...

How to ignore mouse events in a view or window in macOS?

question macOS swift
Ram Patra Published on March 14, 2021

You can ignore mouse events in a window/view by adding just a single line of code.

window.ignoresMouseEvents = true

Or,

view.ignoresMouseEvents = true

Take your presentation to the next level.

Put your face and name on your screen.

Your to-dos on your menu bar.

Fill forms using your right-click menu.

Ram Patra Published on March 14, 2021
Image placeholder

Keep reading

If this article was helpful, others might be too

question swiftui macOS January 26, 2024 How to hide the title bar in a SwiftUI macOS app?

Let’s say you have a view named ContentView and your main App file looks like this:

question macOS swift August 14, 2020 How to quit or close an app in macOS using Swift?

You can quit or exit an app with:NSApp.terminate(self)

question macOS swift November 10, 2021 How to detect fn key press in Swift?

You can override the flagsChanged() method of NSViewController and have your code like below to detect fn key press and release in macOS:

Like my work?

Please, feel free to reach out. I would be more than happy to chat.