Questions tagged [cocoa]
Cocoa is Apple's application-development framework for macOS, consisting of Foundation, Application Kit, and Core Data. Use the "cocoa-touch" tag for iOS questions.
39,618
questions
0
votes
0
answers
8
views
MacOS: floating NSTableRowView rendered outside the TableView frame
I have a TableRowView subclass that needs to stay visible on top of the tableView as it contains the searchField for filtering the list. The implementation simply overrides the isFloating parameter to ...
-1
votes
0
answers
10
views
How to auto-hide NSToolbar with app already fullscreen?
Consider an image viewer app in fullscreen (e.g. Photos.app)
It shows an images overview, and some tools and options in an always visible toolbar.
The moment one image is shown as a full screen ...
0
votes
1
answer
28
views
Can I build a native MacOS desktop GUI using Node.js?
I'm learning how to build native desktop applications but am not yet familiar with the nuances of working with the OS to create interfaces.
Because Node is easy to get started with, I am looking to it ...
0
votes
1
answer
75
views
NSPopover not showing content on macOS Sonoma
I'm experiencing a weird issue where NSPopover doesn't show content. What's also strange is that when inspecting view in Xcode Debug View Hierarchy, it renders all the views as expected.
(https://i....
0
votes
0
answers
31
views
Custom NSView doesn't want to hide
I have a custom NSView class called UpdateProgressHelpView.
It draws a graphic by using a drawRect method. It's too long to paste here.
- (void)drawRect:(NSRect)dirtyRect
{
}
I used it on a custom ...
-1
votes
1
answer
55
views
Is there a way to programmatically change the Emoji Panel on key press in System Settings?
I've been trying to change it trough accessing the plist file but I cant find documentation on how to access it. I'm not sure if it's even possible.
1
vote
1
answer
25
views
Showing Initial Column Sort Header in NSTableView
Working in Swift and AppKit on macOS: I have an NSTableView which is all working as expected - except the table does not show any column header sort indicator when it initially loads.
My table content ...
0
votes
0
answers
9
views
How to get localized bundle display names of _other_ apps
I am writing an app launcher on macos and want to display localized app names. The app is not localized, however I want the app to display localized app names. I'd like to fetch the localized app ...
1
vote
1
answer
74
views
Why this window does not show up at all?
I'm trying to understand how to change data in a variable (var or a label) in between two different views or functions.
I'm migrating from swiftUi, I was used to create stateobject and accessing the ...
0
votes
0
answers
13
views
How to update an NSWindow's content while it is toggling fullscreen?
I have a NSWindow subclass and a custom NSView for its contentView. The drawing is done using Metal or OpenGL and I'm doing that in the NSView's drawRect method.
Now, when entering fullscreen using [...
0
votes
2
answers
63
views
Why this swift code does not show up line and the animation?
Why is the MyViewController does not get's shown in the window although the it's stated in the contentViewController: MyViewController() ?
I'm not on storyboard or XIB and I don't wanna use a nib file....
1
vote
1
answer
29
views
Why this swift code does not show up the textfield?
The code should just view a "Hello, World!" in the window. The window appears but the text is not showing. Why is that?
I can see that the window.makeKeyAndOrderFront(nil) even orders the ...
1
vote
0
answers
60
views
How to draw proper vertical text in a CGContext?
I need to draw an NSAttributedString to a CGContext using a vertical layout orientation (ie. a vertical “writing direction”). It is not sufficient to rotate horizontally-typeset lines of text, because ...
1
vote
0
answers
27
views
NSPasteboard availability after the app exit
ALL,
Have a following question:
If I allocate NSPasteboard, wrote some data into it, the quit the application, that data will still be available? I won't need to do anything extra?
Or there should be ...
-1
votes
1
answer
15
views
How to show the "Revert to Saved" menu item in non-document apps
When creating a new project in Xcode, the default menu bar in the storyboard has a "Revert to Saved" menu item in the "File" menu. However at runtime, in a non-NSDocument app, the ...
0
votes
1
answer
22
views
Programmatically fill one tableview, use IB bindings to fill others
A window is created in a xib, and it contains two tableviews, A and B. In interface builder, both A and B have the File's owner set as the delegate, since both will use some delegate methods, e.g. for ...
0
votes
1
answer
33
views
Get Windows Locale code from preferred language
How can I get the windows locale code from from the first preferredLanguages?
Currently, it return me 12 (in decimal) which doesn't correspond to any windows locale (see: https://learn.microsoft.com/...
0
votes
0
answers
18
views
Text background color for newlines in TextKit 2
When using NSTextLayoutManager.addRenderingAttribute(.backgroundColor, value: NSColor.red, for: range), the background color for a line is only drawn as far as the last visible character. There is ...
0
votes
0
answers
34
views
How to perform artifact-free fast drawing from bitmap data in Cocoa / Objective-C?
Disclaimer: I am mostly experienced with Gtk and FLTK on Linux and Windows. I am pretty much starting my macOS / Cocoa / Objective-C development journey. While I have done much research, I am not ...
2
votes
1
answer
99
views
How to use Swift dylib in Python Project in macOS?
I've simple Swift package created by using command
cd Desktop
mkdir AICore
cd AICore
swift package init --type library
and edited the configuration to dynamic library configuration like below,
...
0
votes
0
answers
50
views
How to make current webpage in WKWebView to receive mouse movements when it isn't focused (key window, on macOS)
I know it's a rare circumstance, however, I have no choice.
I created a NSWindow to be displayed over the desktop as a dynamic wallpaper, setting its styleMask as .borderless to hide its title bar and ...
2
votes
1
answer
85
views
How can I increase the NSStatusBar Image size?
I noticed the image size regardless of which image I use it is slitty smaller than the other apps image in macOS menu bar.
This is the code i used in cocoa:
private lazy var statusItem: NSStatusItem = ...
0
votes
0
answers
18
views
Can I get a localized language name for a locale code in Cocoa? [duplicate]
The [NSSpellChecker availableLanguages] method returns an array of locale codes (like "de", "en_GB" etc.). Is there a way that I can get localized language names (eg. "Deutsch&...
2
votes
0
answers
112
views
(SwiftUI) OpenURLAction is ignored when Text is selectable
I've faced an issue while trying to handle hyperlinks from SwiftUI Text view. If I make a Text selectable, hyperlinks are always treated by system ignoring .environment(\.openURL, OpenURLAction).
let ...
1
vote
0
answers
65
views
NSTableview showing a parenthese instead of array contents - Cocoa Bindings
I have an array IgnoreAppsExpiryDates. I'm using a macro so it's called kIgnoreAppsExpiryDatesKey in the code.
I'm adding strings to the array that represents dates:
if (timeLimitDays)
{
...
0
votes
0
answers
25
views
How to solve ghosting issue of NSWindow without any styleMask?
In my project I want a NSWindow without any styleMask, therefor I am using this code:
class AppDelegate: NSObject, NSApplicationDelegate {
private lazy var window: NSWindow = NSWindow()
...
0
votes
1
answer
67
views
Making cocoa draw(_ dirtyRect) respond to needsDisplay sent from different class
I have a macOS Swift app with two Views. One is a Metal MTKView which draws an animated 3D set of objects and the second is a graph which is drawn using a BezierPath. The Metal view controller class ...
1
vote
0
answers
71
views
How to properly get and set(replace) the comment field in Get Info window of a file programmatically?
I am working on a macOS application using Swift which generates a file on the desktop and I want to get and set the comment field as string using Swift. I don't want to use AppleScript or 3rd party ...
0
votes
0
answers
22
views
How do I keep key focus on both NSPanel and background app?
currently I'm using activate and makeKeyAndOrderFront to "show" and focus a TextEditor on my NSPanel when I pressing a hotkey. However this steals the input focus from other apps. How should ...
0
votes
1
answer
32
views
Changing the position of NSOutlineView disclosure triangle and setting up icons for child nodes
I am creating an OutlineView like this:
And I want to achieve a view which looks like this:
The 2 issues that I am facing are:
I cant find a way to move the disclosure triangle between the folder ...
0
votes
0
answers
38
views
Why doesn't Swift binary built by CMake Ninja generator, generate logs to terminal using Logger framework?
This behaviour is only observed with Ninja generator and not seen with Xcode generator. Just replace Ninja with Xcode in the commands(mentioned below). Is there any post build steps to be run for a ...
0
votes
1
answer
130
views
qt.qpa.plugin: Could not find the Qt platform plugin "cocoa" in ""
I am writing an app using PyQt6, but when it's time to open a simple MainWindow I get the following error:
qt.qpa.plugin: Could not find the Qt platform plugin "cocoa" in ""
This ...
0
votes
1
answer
23
views
Determinate spinning NSProgressIndicator doesn't adapt to frame size and gets cut off
The following code should produce 6 spinning progress indicators of varying sizes: 3 indeterminate and 3 determinate ones. The first two of the 3 determinate ones are either entirely or partially cut ...
2
votes
0
answers
56
views
Memory leak with Cocoa's `addGlobalMonitorForEventsMatchingMask`
I'm facing a tricky issue with Cocoa's addGlobalMonitorForEventsMatchingMask leaking memory over time. In particular, with the flags provided in the example below, some events (eg. Mouse down) cause ...
1
vote
1
answer
53
views
Swift 5.5: How to properly access the notification object inside the notification handler when its object has to be processed on the main queue?
This minimal example
class ViewController : NSViewController {
override func loadView() {
NotificationCenter.default.addObserver(forName: NSView.frameDidChangeNotification, object: view, ...
0
votes
0
answers
27
views
How to make a window behave like an input method or spotlight
How can I make a panel behave like e.g. Spotlight
or the input method
such that
the window does not activate the app
the window does close editors of other windows
the window receives keyboard ...
0
votes
0
answers
17
views
Stackview can't be resized follow the size of NSView
I'm a newbie programmer in Mac software developing and now there is a problem I cannot solve it.
I want to make a Mac software with simple functions.
It looks like the following screenshots, this ...
0
votes
0
answers
14
views
Can't create trait variations for constraints
Hi I'm having a problem adding constraints that are installed based on size classes. I'd like to have certain constraints be installed on compact vertical traits.
I have enabled Use Trait Variations ...
0
votes
0
answers
24
views
Warning when archiving product in Xcode with AppIntent extension
When building my app for debugging in Xcode I don't get any warning, only when archiving the product:
MyIntent.appex is an ExtensionKit extension and must be embedded in the parent app bundle's ...
0
votes
3
answers
72
views
How to create splash screen in flutter?
How to I create splash screen in flutter with timer? I want to user wait 3 second on splash screen and after they redirect to home page.
I want to create splash screen in flutter with 3 second timer. ...
1
vote
0
answers
32
views
Returning another NSView subclass in 'initWithCoder' results in error "This coder requires that replaced objects be returned from initWithCoder""
I want to make a backwards-compatible background view for my application (OS X 10.6+) and then use it inside my Application.xib.
I made a subclass of NSView which returns NSVisualEffectView or NSView (...
-1
votes
1
answer
35
views
Push notification of mac OSX when is force quit
Is it possible to get a callback when a push notification is received but the mac app is force killed ?
-1
votes
1
answer
55
views
Rendering OpenGL within an NSView subclass does not render [closed]
I have existing code that uses an NSOpenGLView.
I would like to instead utilise a subclassed NSView controller, and I'm hiting a few walls (not least since OpenGL is long deprecated on Mac. I am ...
0
votes
0
answers
28
views
Issue with NSTextView and NSView key events
I currently have NSView which receives keyDown: events and I haven't had any issues with it until trying to implement NSTextView with it.
However, I am wanting to handle text input with my application....
0
votes
1
answer
53
views
Why `-[NSProgressIndicator usesThreadedAnimation]` makes app slower?
According to Apple Documentation:
-[NSProgressIndicator usesThreadedAnimation]
When the value of this property is YES, animation of the progress indicator occurs in a separate thread.
If the app ...
0
votes
0
answers
13
views
Autosizing text field: NSCell.cellSize(forBounds:) doesn't respect wrapped text unless using attributed string [duplicate]
I'm trying to implement a text field in a table view that automatically adjusts its height to fit the contained text. My current implementation adjusts its intrinsicContentSize in textDidChange(_:). ...
0
votes
0
answers
10
views
NSTextField in table view with specific configuration doesn't enable undo
After typing anything in a custom text field with undo support, when opening the Edit menu, the undo item is disabled. It seems that setting translatesAutoresizingMaskIntoConstraints=false, a ...
0
votes
0
answers
21
views
Vertical text from left to right with NSTextView
In the WebVTT video subtitle format, subtitles can be horizontal, vertical growing left, or vertical growing right. The natural text direction of NSTextView is horizontal; with setLayoutOrientation(_:)...
1
vote
0
answers
36
views
SwiftUI NSCursor in DragGesture
I'm working on an app in SwiftUI where I want two views to be resizable by dragging on a divider between them. This is working fine, but the cursor seems to change to NSCursor.pointingHand, which is ...
0
votes
0
answers
41
views
How to determine the natural direction of text
NSTextField and NSParagraphStyle have a alignment: NSTextAlignment property that allows to align text to the left, center, right, or natural, which means that text in a left-to-right app UI is aligned ...