Post

Replies

Boosts

Views

Activity

Change anchorpoint of NSView without layer
Hi, Is it possible to change the anchorpoint of NSView if I don't use layer? If not how can I use layer and still draw my notch? import Cocoa import Combine class NotchView: NSView { private var mouseDownSubject = PassthroughSubject<NSPoint, Never>() var mouseDownPublisher: AnyPublisher<NSPoint, Never> { return mouseDownSubject.eraseToAnyPublisher() } //Draw notch override func draw(_ dirtyRect: NSRect) { super.draw(dirtyRect) drawNotch() } func drawNotch () { let size = self.frame.size let r: CGFloat = 16.0 let gap: CGFloat = 1.0 let notch = NSBezierPath() notch.move(to: NSPoint(x: 0.0, y: size.height)) notch.curve(to: NSPoint(x: r, y: size.height - r), controlPoint1: NSPoint(x: r - gap, y: size.height), controlPoint2: NSPoint(x: r, y: size.height - gap)) notch.line(to: NSPoint(x: r, y: r)) notch.curve(to: NSPoint(x: 2 * r, y: 0.0), controlPoint1: NSPoint(x: r, y: gap), controlPoint2: NSPoint(x: r + gap, y: 0.0)) notch.line(to: NSPoint(x: size.width - 2 * r, y: 0.0)) notch.curve(to: NSPoint(x: size.width - r, y: r), controlPoint1: NSPoint(x: size.width - r - gap, y: 0.0), controlPoint2: NSPoint(x: size.width - r, y: gap)) notch.line(to: NSPoint(x: size.width - r, y: size.height - r)) notch.curve(to: NSPoint(x: size.width, y: size.height), controlPoint1: NSPoint(x: size.width - r, y: size.height - gap), controlPoint2: NSPoint(x: size.width - r + gap, y: size.height)) notch.close() NSColor.systemPink.setFill() //change to black to see the notch notch.fill() } //Tap with mouse override func mouseDown(with event: NSEvent) { super.mouseDown(with: event) //move notch to top mouseDownSubject.send(event.locationInWindow) } }
0
0
599
Jul ’23
NSWindow not release memory
Hi, How can I release my NSWindow manually? when the user tap on red close button? @objc func windowWillClose() { // Handle the window closing event here // You can perform any necessary cleanup or ask the user for confirmation // Return true to allow the window to close _window?.contentViewController = nil _window?.delegate = nil _window = nil NotificationCenter.default.removeObserver(self, name: NSWindow.willCloseNotification, object: nil) } //Settings cell tap @objc func settingsItemClicked () { //_window:NSWindow? NotificationCenter.default.addObserver(self, selector: #selector(windowWillClose), name: NSWindow.willCloseNotification, object:_window) if _window?.isVisible == false { // Load the view controller from the storyboard let storyboard = NSStoryboard(name: "Main", bundle: nil) guard let ViewController = storyboard.instantiateController(withIdentifier: "SettingsViewController") as? SettingsViewController else { fatalError("Unable to instantiate SettingsViewController from storyboard.") } // _window.delegate = self // Set the view controller as the content view controller of the window _window?.contentViewController = ViewController _window?.isReleasedWhenClosed = false _window?.hidesOnDeactivate = true // Set the window's title _window?.title = "DynamicLake" // Show the window _window?.makeKeyAndOrderFront(self) }else{ print("The settings view is already open") } }
2
0
1.2k
Aug ’23
Resize NSProgressIndicator
Hi, How is it possible to make NSProgressIndicator smaller ? When I use style property the thickness is also change This is the size that I want (it's from Xcode) it's with regular size style but it's smaller in size And this is my attempt
0
0
509
Feb ’24
IBAction not work with scrollview
Hi, I'm using NSSplitViewController and once I load a viewcontroller with scrollview the IBActions of NSSwitch,NSButtons etc not work after I added the scrollview How can I fix it? import Foundation //Categories Protocal delegate protocol CategoriesViewControllerDelegate: AnyObject { func didSelectCategory(category: String) } class DetailViewController:NSViewController, NSOutlineViewDataSource, CategoriesViewControllerDelegate { weak var delegate: CategoriesViewControllerDelegate? override func viewDidLoad() { // Other setup code... detViewController = self loadViewControllerWithScrollView(GeneralSettingsViewController.self, storyboardIdentifier: "GeneralSettingsViewController", originalViewController: self) } func didSelectCategory(category: String) { // Handle the selected category in DetailViewController print("Selected category: \(category)") // Load the corresponding view controller or perform any other actions switch category { case "General": // Load GeneralSettingsViewController // Example: self.replaceCurrentViewController(with: GeneralSettingsViewController()) print("Load GeneralSettingsViewController") loadViewControllerWithScrollView(GeneralSettingsViewController.self, storyboardIdentifier: "GeneralSettingsViewController", originalViewController: self) case "DynaMusiX": // Load DynaMusicSettingsViewController // Example: self.replaceCurrentViewController(with: DynaMusicSettingsViewController()) print("Load DynaMusicSettingsViewController") loadViewControllerWithScrollView(DynaMusicSettingsViewController.self, storyboardIdentifier: "DynaMusicSettingsViewController", originalViewController: self) case "DynaGlance": // Load DynaGlanceSettingsViewController // Example: self.replaceCurrentViewController(with: DynaGlanceSettingsViewController()) print("Load DynaGlanceSettingsViewController") loadViewControllerWithScrollView(DynaGlanceSettingsViewController.self, storyboardIdentifier: "DynaGlanceSettingsViewController", originalViewController: self) default: break } } } //Load viewcontroller with scrollview func loadViewControllerWithScrollView<T: NSViewController>(_ viewControllerType: T.Type, storyboardIdentifier: String, originalViewController: NSViewController) { let storyboard = NSStoryboard(name: NSStoryboard.Name("Main"), bundle: nil) let newViewController = storyboard.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier(storyboardIdentifier)) as! T // Remove existing child view controllers for childVC in originalViewController.children { childVC.removeFromParent() childVC.view.removeFromSuperview() } // Wrap the new view controller's view in a scroll view let scrollView = NSScrollView() scrollView.documentView = newViewController.view scrollView.autoresizingMask = [.width, .height] scrollView.hasVerticalScroller = true scrollView.hasHorizontalScroller = false scrollView.contentView.scroll(to: NSPoint(x: 0, y: newViewController.view.frame.height)) scrollView.translatesAutoresizingMaskIntoConstraints = true // Set user interaction for the content view inside the scroll view scrollView.documentView?.translatesAutoresizingMaskIntoConstraints = true scrollView.documentView?.needsLayout = true // Add the scroll view as a subview of the original view controller originalViewController.view.addSubview(scrollView) scrollView.frame = originalViewController.view.bounds scrollView.layer?.zPosition = -1 } t
0
0
492
Feb ’24
Change anchorpoint of NSView without layer
Hi, Is it possible to change the anchorpoint of NSView if I don't use layer? If not how can I use layer and still draw my notch? import Cocoa import Combine class NotchView: NSView { private var mouseDownSubject = PassthroughSubject<NSPoint, Never>() var mouseDownPublisher: AnyPublisher<NSPoint, Never> { return mouseDownSubject.eraseToAnyPublisher() } //Draw notch override func draw(_ dirtyRect: NSRect) { super.draw(dirtyRect) drawNotch() } func drawNotch () { let size = self.frame.size let r: CGFloat = 16.0 let gap: CGFloat = 1.0 let notch = NSBezierPath() notch.move(to: NSPoint(x: 0.0, y: size.height)) notch.curve(to: NSPoint(x: r, y: size.height - r), controlPoint1: NSPoint(x: r - gap, y: size.height), controlPoint2: NSPoint(x: r, y: size.height - gap)) notch.line(to: NSPoint(x: r, y: r)) notch.curve(to: NSPoint(x: 2 * r, y: 0.0), controlPoint1: NSPoint(x: r, y: gap), controlPoint2: NSPoint(x: r + gap, y: 0.0)) notch.line(to: NSPoint(x: size.width - 2 * r, y: 0.0)) notch.curve(to: NSPoint(x: size.width - r, y: r), controlPoint1: NSPoint(x: size.width - r - gap, y: 0.0), controlPoint2: NSPoint(x: size.width - r, y: gap)) notch.line(to: NSPoint(x: size.width - r, y: size.height - r)) notch.curve(to: NSPoint(x: size.width, y: size.height), controlPoint1: NSPoint(x: size.width - r, y: size.height - gap), controlPoint2: NSPoint(x: size.width - r + gap, y: size.height)) notch.close() NSColor.systemPink.setFill() //change to black to see the notch notch.fill() } //Tap with mouse override func mouseDown(with event: NSEvent) { super.mouseDown(with: event) //move notch to top mouseDownSubject.send(event.locationInWindow) } }
Replies
0
Boosts
0
Views
599
Activity
Jul ’23
Airplane mode on watchOS
Hi, Is it possible to turn on airplane mode on watchOS using swift? or possible to know the state of airplane mode? thank you
Replies
1
Boosts
0
Views
1k
Activity
Aug ’23
NSWindow not release memory
Hi, How can I release my NSWindow manually? when the user tap on red close button? @objc func windowWillClose() { // Handle the window closing event here // You can perform any necessary cleanup or ask the user for confirmation // Return true to allow the window to close _window?.contentViewController = nil _window?.delegate = nil _window = nil NotificationCenter.default.removeObserver(self, name: NSWindow.willCloseNotification, object: nil) } //Settings cell tap @objc func settingsItemClicked () { //_window:NSWindow? NotificationCenter.default.addObserver(self, selector: #selector(windowWillClose), name: NSWindow.willCloseNotification, object:_window) if _window?.isVisible == false { // Load the view controller from the storyboard let storyboard = NSStoryboard(name: "Main", bundle: nil) guard let ViewController = storyboard.instantiateController(withIdentifier: "SettingsViewController") as? SettingsViewController else { fatalError("Unable to instantiate SettingsViewController from storyboard.") } // _window.delegate = self // Set the view controller as the content view controller of the window _window?.contentViewController = ViewController _window?.isReleasedWhenClosed = false _window?.hidesOnDeactivate = true // Set the window's title _window?.title = "DynamicLake" // Show the window _window?.makeKeyAndOrderFront(self) }else{ print("The settings view is already open") } }
Replies
2
Boosts
0
Views
1.2k
Activity
Aug ’23
Handle touchbar volume slider
Hi, Is it possible to handle touchbar volume slider (not volume buttons) I want to print hello when the user use volume slider on touchbar
Replies
0
Boosts
0
Views
577
Activity
Sep ’23
Is it possible to get all URL of Safari/Chrome open tabs?
Hi. Is it possible to get all Safari/Chrome open tabs with AppleScript? Is it also possible to check if tab audio is enable/play video/music? macOS Thank you!
Replies
1
Boosts
0
Views
947
Activity
Nov ’23
Draw Line animation on macOS
Hi, What is the best way to make this animation with Swift and UIKit? [Animation:](https://dribbble.com/shots/4247369-Loading-notch /) Thank you!
Replies
0
Boosts
0
Views
571
Activity
Dec ’23
How to make Dynamic Island music animation?
How is it possible to remake the Dynamic Island music spectrum (visual EQ) animation on macOS? I see WhatsApp have a similar animation on voice calls. Is there a 3rd or native Apple library to make it? https://imgur.com/a/PKDkosC
Replies
0
Boosts
0
Views
801
Activity
Dec ’23
Check for a new mail (macos)
Hi, How is it possible to check if I have a new mail? Is it possible to do it with ScriptingBridge? Thank you!
Replies
1
Boosts
0
Views
797
Activity
Jan ’24
Resize NSProgressIndicator
Hi, How is it possible to make NSProgressIndicator smaller ? When I use style property the thickness is also change This is the size that I want (it's from Xcode) it's with regular size style but it's smaller in size And this is my attempt
Replies
0
Boosts
0
Views
509
Activity
Feb ’24
IBAction not work with scrollview
Hi, I'm using NSSplitViewController and once I load a viewcontroller with scrollview the IBActions of NSSwitch,NSButtons etc not work after I added the scrollview How can I fix it? import Foundation //Categories Protocal delegate protocol CategoriesViewControllerDelegate: AnyObject { func didSelectCategory(category: String) } class DetailViewController:NSViewController, NSOutlineViewDataSource, CategoriesViewControllerDelegate { weak var delegate: CategoriesViewControllerDelegate? override func viewDidLoad() { // Other setup code... detViewController = self loadViewControllerWithScrollView(GeneralSettingsViewController.self, storyboardIdentifier: "GeneralSettingsViewController", originalViewController: self) } func didSelectCategory(category: String) { // Handle the selected category in DetailViewController print("Selected category: \(category)") // Load the corresponding view controller or perform any other actions switch category { case "General": // Load GeneralSettingsViewController // Example: self.replaceCurrentViewController(with: GeneralSettingsViewController()) print("Load GeneralSettingsViewController") loadViewControllerWithScrollView(GeneralSettingsViewController.self, storyboardIdentifier: "GeneralSettingsViewController", originalViewController: self) case "DynaMusiX": // Load DynaMusicSettingsViewController // Example: self.replaceCurrentViewController(with: DynaMusicSettingsViewController()) print("Load DynaMusicSettingsViewController") loadViewControllerWithScrollView(DynaMusicSettingsViewController.self, storyboardIdentifier: "DynaMusicSettingsViewController", originalViewController: self) case "DynaGlance": // Load DynaGlanceSettingsViewController // Example: self.replaceCurrentViewController(with: DynaGlanceSettingsViewController()) print("Load DynaGlanceSettingsViewController") loadViewControllerWithScrollView(DynaGlanceSettingsViewController.self, storyboardIdentifier: "DynaGlanceSettingsViewController", originalViewController: self) default: break } } } //Load viewcontroller with scrollview func loadViewControllerWithScrollView<T: NSViewController>(_ viewControllerType: T.Type, storyboardIdentifier: String, originalViewController: NSViewController) { let storyboard = NSStoryboard(name: NSStoryboard.Name("Main"), bundle: nil) let newViewController = storyboard.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier(storyboardIdentifier)) as! T // Remove existing child view controllers for childVC in originalViewController.children { childVC.removeFromParent() childVC.view.removeFromSuperview() } // Wrap the new view controller's view in a scroll view let scrollView = NSScrollView() scrollView.documentView = newViewController.view scrollView.autoresizingMask = [.width, .height] scrollView.hasVerticalScroller = true scrollView.hasHorizontalScroller = false scrollView.contentView.scroll(to: NSPoint(x: 0, y: newViewController.view.frame.height)) scrollView.translatesAutoresizingMaskIntoConstraints = true // Set user interaction for the content view inside the scroll view scrollView.documentView?.translatesAutoresizingMaskIntoConstraints = true scrollView.documentView?.needsLayout = true // Add the scroll view as a subview of the original view controller originalViewController.view.addSubview(scrollView) scrollView.frame = originalViewController.view.bounds scrollView.layer?.zPosition = -1 } t
Replies
0
Boosts
0
Views
492
Activity
Feb ’24
Improve CPU usage for auto scroll text
Hi, How can I improve the CPU usage of my auto scrolling text (horizontal)? Currently I use very short timer Thank you Code: https://codeshare.io/Q8A1JJ
Replies
0
Boosts
0
Views
531
Activity
Aug ’24
Bluetooth notifications
REMOVED
Replies
0
Boosts
0
Views
605
Activity
Sep ’24
window level popUpMenu and view behind it
Hi, I'm using NSPanel that his level is .popUpMenu and when I use .quickLookPreview in SwiftUI it make the the Quick Look behind the nspanel how can I fix it without change the level of NSPanel?
Replies
1
Boosts
0
Views
581
Activity
Oct ’24
Application iCloud folder doesn't show in macOS
Hi, I'm working on integrating iCloud Drive functionality into my app. I noticed that the folder for my app appears under /Users/USERNAME/Library/Mobile Documents/MY_CONTAINER, but it doesn't show up in iCloud Drive. Am I missing a step in the setup or configuration? Any guidance would be appreciated! Thanks!
Replies
1
Boosts
0
Views
525
Activity
Dec ’24
Can't run UITests after added iCloud
Hi After I added iCloud container and iCloud documents my UITests can't run anymore what is this problem and how can I solve it? Thanks!
Replies
1
Boosts
0
Views
442
Activity
Dec ’24