Create Spotlight-Like Window in Swift 4

Making Spotlight Search Bar like view in Objc/Swift

Solved. By adding subviews to visualEffectView instead of self.

How to show a window without stealing focus on macOS?

I've been playing around with this a bit, and I seem to be able to produce this effect when the frontmost window is not from the same process as the frontmost application, which is what I suspect Spotlight is probably doing. I can achieve this like so:

  1. Set LSUIElement to YES in my app's Info.plist.

  2. In Interface Builder, set the window's class to NSPanel, check "Non Activating" in the Attributes Inspector, and set "isFloatingPanel" to YES in the User Defined Runtime Attributes under the Identity Inspector.

  3. During some time that some other application is in front (I just used a 5-second delay to give myself time to pop some other app to the front and select a text field), call makeKeyAndOrderFront() followed by orderFrontRegardless() on the window.

When I do this, I get the following (note the focus ring still drawn on Xcode's "Module" field):

Sample Image

Make NSPanel always on top

This works for me

panel.level = .mainMenu

How to continue spotlight search and show content ViewController

even I have same problem in my one of the app. Then I was surfing on internet for solution, here the best sample example and code along with it's explanation.

  func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([Any]?) -> Void) -> Bool {

guard userActivity.activityType == Employee.domainIdentifier,
let objectId = userActivity.userInfo?["id"] as? String else {
return false
}

if let nav = window?.rootViewController as? UINavigationController,
let listVC = nav.viewControllers.first as? EmployeeListViewController,
let employee = EmployeeService().employeeWithObjectId(objectId) {
nav.popToRootViewController(animated: false)

let employeeViewController = listVC
.storyboard?
.instantiateViewController(withIdentifier: "EmployeeView") as!
EmployeeViewController

employeeViewController.employee = employee
nav.pushViewController(employeeViewController, animated: false)
return true
}

return false
}


Related Topics



Leave a reply



Submit