Post not yet marked as solved
I am seeking for this User Interface(UI) effect --> "Spotlight" a specific IBOutlet (Please see attached Image2.png below) for a week!
Explain the "Spotlight" effect : I wish to create is effect similar to NSAlert or beginSheet effect which user cannot click or access the entire window/view until user trigger a button and it back to normal. The whole window/view will becoming darken or gray EXCEPT a specific button I allow my user to interact with.
Yet, I found that there is no any trick to create such effect neither in XIB file nor objective-c code.
This is urgent for me. Eagerly waiting for your reply. Much Appreciated.
(Image 1.png)
(Image 2.png)
Post not yet marked as solved
Platform: macOS 12.3.1
Xcode: 13.3
I had Xcode ARC turned ON.
AppleScript should be declared like below.
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:strScript];
When call AppleScript, open "Monitor.app" app will observe some memory leak.
I try to wrap AppleScript by autoReleasePool. Memery leak still exists
@autoreleasepool {
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:strScript];
//script to do something
}
Is there other suggestion to do gabage collection to release memory?
Post not yet marked as solved
Hi there,we are getting frequent questions from our user base when they cannot find options in the print dialog of our app because the details in NSPrintPanel are not expanded by default.Is there a way to always expand the details section programmatically to make it easier for our non-technical user base to find the app specific print settings..?Browsing the NSPrintPanel documentation didn't reveal anything obvious..Cheers,Jay
Post not yet marked as solved
The PDFDocument class makes updating metadata attributes simple but appears to:Disallow arbitrary values for the /Producer attribute - the wite action substitutes an Apple string as the producerOffer no choice over the PDF version or the write format - it's 1.4, and compressed regardless of the original PDF formatAm I missing something simple in the PDFDocument class that will over-ride this behaviour?Is the PDFDocument structure archive conformant and, if so, to what level?Is it necessary to deal directly with CGPDFDocument to overcome these limitations?cheers,david
Post marked as Apple Recommended
As someone who learned to program on Mac OS 7.5.5, I don't mind the return of Clarus the dogcow! However others on my team are wondering if there will be a way for our app to still use the system Page Setup dialog, but not display Clarus (basically retain the appearance of Monterey's Page Setup).
Anyone know what the plan is for Clarus in the official Ventura release? Will it be possible to hide the dogcow, or substitute a different preview graphic?
Post not yet marked as solved
I have created my first app with python using py2app and it build my app successfully but when I try to open it, it crash but when I open it's package and run it from this path: myapp.app/contents/macos/myapp
it open console and run my app correctly without any error.
I can't understand how to read this kind of mac errors. I will be happy if you can help me with that:
Error Text
I have a SwiftUI view which contains an NSTableView wrapped with an NSViewControllerRepresentable struct. This has a Coordinator, which I set up as the NSTableView's delegate. There is an implementation of tableViewSelectionDidChange to pass the selected row index up to the enclosing view.
The problem is that I can click and select a row, but the selection disappears, usually on the first click, and always when clicking a column header to sort. I have looked at the various delegate methods for notifying about selection changing, and they don't seem to be called.
How can I find where the selection is being changed?
Post not yet marked as solved
Hello,
I‘m trying to create an app with one NSPopUpButton and two NSTextFields.
The first control is the NSPopUpButton and I want to make it the initialFirstResponder. When the app starts, it always skips the popUpButton and the focus is on the first textField. I already tried to subclass the popUpButton and to override canBecomeKeyView.
Maybe someone has a hint. Thanks.
Post not yet marked as solved
Below is a custom view class:
class MyView: NSView {
var xloc = 0.0
var yloc = 0.0
var width = 400.0
var height = 200.0
var myRect = NSRect(x: 0.0, y: 0.0, width: 400.0, height: 200.0)
...
override func draw(_ dirtyRect: NSRect) {
let myColor = NSColor(red: 1.0, green: 1.0, blue: 1.0, alpha: self.alpha)
myColor.setFill()
dirtyRect.fill()
self.myRect = NSRect(x: self.xloc, y: self.yloc, width: self.width, height: self.height)
self.setNeedsDisplay(myRect)
self.myRect.fill(using: NSCompositingOperation.clear)
}
The view controller has a keyDown handler as follows:
override func viewDidLoad() {
super.viewDidLoad()
view.window?.backgroundColor = NSColor.white
NSEvent.addLocalMonitorForEvents(matching: .keyDown) {
self.keyDown(with: $0)
return $0
}
}
override func keyDown(with event: NSEvent) {
let theView = self.view as! MyView
if event.keyCode == 126 {
NSLog("Increasing Y coordinate")
theView.yloc = theView.yloc + 10
self.view.display()
}
}
Below is the AppDelegate.swift's content:
func applicationDidFinishLaunching(_ aNotification: Notification) {
let window = NSApplication.shared.windows.first
window?.isOpaque = false
window?.backgroundColor = NSColor.clear
window?.ignoresMouseEvents = true
window?.toggleFullScreen(self)
window?.collectionBehavior = NSWindow.CollectionBehavior.fullScreenPrimary
let screenFrame = NSScreen.main?.frame
window?.setFrame(screenFrame!, display: true)
let myView = MyView()
window?.contentView = myView
}
The rectangular hole is seen on the screen initially
The above handler is called whenever I press the up arrow key. The self.view.display() in turn calls the draw() method on the view. But the NSRect is not drawn in the new position. Request you to please help me with this. The expected result is to move (or rather redraw) the NSRect based on the keyboard up arrow click
Currently incomplete code is at: https://github.com/suchindrac/hide_pane_mac
Post not yet marked as solved
When I hover the mouse over the NSTextAttachment image inside the UITextview, it should show this option to MarkUp. All native app including Notes, TextEditor, Mail have this behaviour:
I think, by default, NSTextView will show the NSSharingServicePicker button when you hover over an image inside the text view. That’s true even for custom image-based NSTextAttachments in the attributed string.
But it is not showing the button for UITextview in MacCatalyst. Also NSSharingService class is limited to MacOS only.
Are there any alternative way to achieve this in MacCatalyst?
Post not yet marked as solved
Is there any particular reason why a WKWebView instance set as the contentView of a NSWindow would not display web content when the window is displayed using the runModalForWindow method of NSApplication?If I display the window using the showWindow method of NSWindowController, it displays correctly.If I replace the WKWebView instance with a WebView instance, the web content displays correctly whether the window is shown modally or not.In all cases I am calling loadRequest: in windowDidLoad.Bruce
Post not yet marked as solved
What is the Objective C equivalent of the command line
diskutil unmount force
?
I've completed a simple app that plays 3D video. Now, I'm trying to make it open files from the menu, as well as using the Cmd-O keyboard shortcut.
But the "Open" menu item in the "File" menu is gray - I don't know exactly what this means, but it seems that the current form of the app doesn't support openning files.
I've had a func application(_ application: NSApplication, openFile filename: String) -> Bool function in my app delegate, I've had a CFBundleDocumentTypes with an entry of the MIME type of "video/mp4".
What am I doing wrong?
Post not yet marked as solved
I have a DLP-Link 3D projector which I'd like to make use of by means of a hand-made player.
So far in my project: A class MovieView : NSView within a NSWindow, with stub drawing codes.
I know that, if I place drawing codes in the func draw(...) function, then NSGraphicsContext.current will be set up for me to use. But I'm drawing from a high-priority thread (the DisplayLink), so I obviously have to set it up myself.
How should I do that in Swift?
Post not yet marked as solved
I'm experimenting with the Accessibility API and I'm currently trying to interrogate the system wide accessibility element.According to AXUIElementCopyAttributeNames the system wide element has 4 attributes (AXRole, AXRoleDescription, AXFocusedUIElement & AXFocusedApplication).I can successfully use the following chunk of code to get the attribute value for the AXRole and AXRoleDescription elements but when I try to get the value of the AXFocusedUIElement or AXFocusedApplication attributes AXUIElementCopyAttributeValue returns kAXErrorCannotComplete.AXUIElementRef systemWideElement = AXUIElementCreateSystemWide();
CFStringRef attrName = kAXFocusedApplicationAttribute;
CFTypeRef value = NULL;
res = AXUIElementCopyAttributeValue(systemWideElement, attrName, &value);
if (res != kAXErrorSuccess)
NSLog(@"Failed to get element attribute %@ (%d)", attrName, (int)res);
if (value)
CFRelease(value);Does anybody know why AXUIElementCopyAttributeValue is returning kAXErrorCannotComplete / what I'm doing wrong?Thanks
I would like to create a macOS app without using Interface Builder.How must the Xcode macOS app template be modified after deleting Main.storyboard and its corresponding Info.plist lineto show a single simple window at startup?
Post not yet marked as solved
When I tried this, the app crashed immediately with a requirement to use NSTextContentStorage subclass
Post not yet marked as solved
I was able to implement drag and drop with NSTableViewDiffableDataSource by subclassing and adding the missing methods. It works but the draggingSession willBeginAt method is never called so I can't provided a custom preview to the dragging. Any tips from AppKit developers or Apple engineers?
class ListCoordinator: NSTableViewDiffableDataSource<String, Int>, NSTableViewDelegate {
@objc func tableView(_ tableView: NSTableView, pasteboardWriterForRow row: Int) -> NSPasteboardWriting? {
return NSPasteboardItem(pasteboardPropertyList: row.formatted(), ofType: .string)
}
@objc func tableView(_ tableView: NSTableView, validateDrop info: NSDraggingInfo, proposedRow row: Int, proposedDropOperation dropOperation: NSTableView.DropOperation) -> NSDragOperation {
return .move
}
@objc func tableView(_ tableView: NSTableView, acceptDrop info: NSDraggingInfo, row: Int, dropOperation: NSTableView.DropOperation) -> Bool {
...
return true
}
@objc func tableView(_ tableView: NSTableView, draggingSession session: NSDraggingSession, willBeginAt screenPoint: NSPoint, forRowIndexes rowIndexes: IndexSet) {
// NEVER CALLED
}
}
Post not yet marked as solved
I'm now trying to add Drag & Drop feature to my NSTableView which uses NSTableViewDiffableDataSource for its data source. However, I can't implement the methods for Drag & Drop like tableView(:, acceptDrop:, row:, dropOperation:).
My code looks like this:
swift
class MyViewController: NSViewController {
private let tableView: NSTableView = {...}()
private lazy var dataSource = MyDataSource(tableView: tableView)
...
}
class MyDataSource: NSTableViewDiffableDataSourceSection, Model {
...
override func tableView(_ tableView: NSTableView, draggingSession session: NSDraggingSession, willBeginAt screenPoint: NSPoint, forRowIndexes rowIndexes: IndexSet) {
...
}
}
Since NSTableViewDiffableDataSource implements NSTableViewDataSource protocol which provides Drag & Drop methods, I thought the above overriding method would work but I got this error.
Method does not override any method from its superclass
What happened? And if this is expected, how can I implement Drag & Drop with NSTableViewDiffableDataSource?
Post not yet marked as solved
I'm getting some Crash Reports for an app of mine that's on the Mac App Store. A few details:
-All the crash reports are on ARM-64 Macs.
-The call stack shows my app calling NSURL's -getResourceValue:forKey: method with NSURLLocalizedNameKey, which is the last call made by my app before the crash. After that crash logs look like this:
**Thread 0 Crashed:
0 libobjc.A.dylib 0x00000001a623c4b0 objc_retain + 16
1 LaunchServices 0x00000001a6954f68 -[FSNode(PathAndName) nameWithError:] + 72
2 LaunchServices 0x00000001a6a36278 +[_LSDisplayNameConstructor(ConstructForAnyFile) displayNameConstructorWithContextIfNeeded:bundle:bundleClass:node:preferredLocalizations:error:] + 2732
3 LaunchServices 0x00000001a6a357ac +[_LSDisplayNameConstructor(ConstructForAnyFile) displayNameConstructorWithContextIfNeeded:node:error:] + 44
4 LaunchServices 0x00000001a6ae5b20 LaunchServices::URLPropertyProvider::getDisplayNameConstructor(LaunchServices::Database::Context&, FSNode*, LaunchServices::URLPropertyProvider::State*, NSError* __autoreleasing*) + 88
5 LaunchServices 0x00000001a6ae1930 LaunchServices::URLPropertyProvider::prepareLocalizedNameValue(LaunchServices::Database::Context&, FSNode*, __FileCache*, __CFString const*, LaunchServices::URLPropertyProvider::State*, NSError* __autoreleasing*) + 328
6 LaunchServices 0x00000001a6953d6c LaunchServices::URLPropertyProvider::prepareValues(__CFURL const*, __FileCache*, __CFString const* const*, void const**, long, void const*, __CFError**) + 456
7 CoreServicesInternal 0x00000001a8def6f0 prepareValuesForBitmap(__CFURL const*, __FileCache*, _FilePropertyBitmap*, __CFError**) + 452
8 CoreServicesInternal 0x00000001a8dec5ec _FSURLCopyResourcePropertyForKeyInternal(__CFURL const*, __CFString const*, void*, void*, __CFError**, unsigned char) + 236
9 CoreFoundation 0x00000001a64546b0 CFURLCopyResourcePropertyForKey + 144
10 CoreFoundation 0x00000001a646b944 -[NSURL getResourceValue:forKey:error:] + 120**
--
I haven't been able to reproduce the issue on my ARM-64 Mac. Not sure what's going with _LSDisplayNameConstructor or if there is a way I can workaround/resolve.
Some of the crashes have the following lines included:
Kernel Triage:
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get