appkit Questions

2

Solved

In my MacOS SwiftUI App I want to display some views in new Windows. The calls shall be possible from several parts of the code so I decided, do implement it as a static func of as special struct l...
Dateless asked 1/5, 2021 at 8:27

2

Solved

I'm trying to handle shift+enter for newline in a text box (that chat apps e.g. WhatsApp, Discord etc. implement). Currently, I'm using a SwiftUI TextEditor, but that doesn't have any way to handle...
Icon asked 15/5, 2022 at 10:44

4

Solved

In Cocoa/AppKit, given a screen from [NSScreen screens], how can I find out if there's a full-screen app running on that specific screen? I'm mostly interested in apps that use the Cocoa APIs for f...
Vaudevillian asked 24/5, 2014 at 10:56

6

I'm developing a Python-based graphic calculator for MacOS using SwiftUI. https://github.com/snakajima/macplot I am using SwiftUI's TextEditor as the editor for Python code, but I am not able to fi...
Aparejo asked 20/3, 2021 at 13:4

2

I am using a custom mouseMove event in NSTextView to set the cursor to a pointer when it's outside the content insets. When it's inside the editable area, I'm calling [super mouseMove]: - (void)mou...
Casia asked 3/11, 2020 at 11:58

2

I want to use SwiftUI View to print something like labels on macOS (Ventura). But that results in a blank paper: func startPrinting() { let printView = NSHostingView(rootView: Text("I want to...
Vituperation asked 15/11, 2022 at 4:26

1

Context I have a Mac app that runs from the status bar. When an NSStatusItem is clicked, I display an NSWindow rather than the standard NSMenu. Problem Before Sonoma, when the NSStatusItem was clic...
Imprimis asked 6/10, 2023 at 7:32

2

I want to set a picker button borderless and transparent in SwiftUI on macOS. I tried using .background(), .border() and .opacity() modifiers on the Picker view. However, I can't change the backgr...
Prohibitory asked 25/10, 2019 at 23:45

2

Solved

Recent Apple products have the Globe (🌐︎) key on the keyboard. At the AppKit level, it is actually just a fn key that behaves as NSEvent.ModifierFlags.function. But is there any way to know whethe...
Spirketing asked 29/11, 2023 at 17:10

6

I have been reading through the various options on how to set the vertical alignment on an NSTextField. I want the text to be displayed in the center and to do it programatically in Swift. Here are...
Pandarus asked 20/12, 2015 at 8:54

2

Solved

I am using Xcode to develop a MacOS app, based on Cocoa & AppKit, written in Swift. I am using IOBluetoothDevice objects throughout my app, and I want to be able to display the devices' batter...
Nubianubian asked 21/4, 2019 at 18:6

6

I use Mac OS X Lion and Python 2.7. I am new to python. Can anyone tell me how to import AppKit and PyObjC to Python. But i get the errors when trying to import Import Error: No module named AppKit...
Quinby asked 7/10, 2012 at 9:35

2

It is the first time for me working with AppKit and a NSTableView. It is backed by a NSFetchedResultsController for Core Data. When there are changes to the dataset, a Notification is being sent: f...
Tbar asked 15/6, 2022 at 15:48

5

UPDATE: 14 months later, there is this intriguing note in the AppKit release notes: A TextField that you are editing inside a selected List row now has correct text foreground colors. (68545878) ...
Grande asked 20/8, 2019 at 14:41

2

Solved

All native controls have different appearance when their parent window is active or inactive. How should we check this state in custom components e.g. while rendering a button cell? We could inspe...
Dyslogia asked 3/10, 2019 at 10:4

0

I'd like to have an item in the macOS menubar that takes the whole height of the bar. This can be seen, for example, in FaceTime's UI: In my attempts, I can only get the item to extend to 1pt away...
Echinoderm asked 21/4, 2023 at 16:24

1

Solved

I'm trying to get the selected text when the user presses a global shortcut. My app should read the text which is currently selected no matter if the currently focused app is chrome, safari or Micr...
Fairground asked 13/4, 2023 at 20:31

2

Solved

In Safari, I can drag an item (like a URL or even a .webloc bookmark from the finder) right onto a tab to open. How do I make the window tab bar item view a drop target in my own AppKit app? I’d l...
Hamlin asked 6/3, 2023 at 15:2

3

Solved

This is as simple as can be so I can't for the life of me find what's wrong, I looked through the documentation as a guide but it still didn't work. I have a view inside a larger view. An IBAction ...
Provo asked 22/8, 2014 at 21:55

0

I have a Mac App that's mostly written in AppKit. Over time, I'm adding new views in SwiftUI, and all the while I've been using SwiftUI previews to preview both my new SwiftUI views, and my old App...
Motherofpearl asked 23/12, 2022 at 22:37

2

Solved

Context In a Mac app built with Swift 5.x and Xcode 14, I have a controller object. This object has several @Published properties that are observed by SwiftUI views, so I have placed the object on ...
Silvereye asked 8/12, 2022 at 10:42

0

I'd like to drag a file in my application (representing a file on a network drive) to the user's Desktop or Finder window. Consequently the file should only be downloaded once the drag & drop o...
Artillery asked 15/11, 2022 at 16:57

4

Solved

I'm subclassing NSButtonCell to customize the drawing (customizable theme). I'd like to customize the way checkboxes and radio buttons are drawn. Does anyone know how to detect whether a button is...
Protolanguage asked 17/10, 2012 at 13:57

1

SwiftUI 2.0 | Swift 5.4 | Xcode 12.4 | macOS Big Sur 11.4 In iOS there is a way to render SwiftUI views to a UIImage that doesn't work in AppKit, only UIKit: extension View { func snapshot() ->...
Impeach asked 25/4, 2021 at 19:35

1

Solved

I'm building a macOS application that requires monitoring global keystrokes. So the global event listener would be: NSEvent.addGlobalMonitorForEvents(matching: NSEvent.EventTypeMask.keyDown) { (eve...
Connect asked 22/1, 2022 at 16:33

© 2022 - 2025 — McMap. All rights reserved.