Post

Replies

Boosts

Views

Activity

CGWindowListCreateImage -> ScreenCaptureKit
So I'm building a colour sampler tool, similar to ColorSlurp and since CGWindowListCreateImage (which I am using for below macOS 14.0) is deprecated since Sonoma, I am wondering what's the best approach to replacing it. The way I use CGWindowListCreateImage currently is to take a screenshot of a specified area around the mouse pointer every time the mouse moves. Which works perfectly fine without issues. Now I've tried replacing CGWindowListCreateImage with SCScreenshotManager.createImage which is an async function and as you might expect, running async functions on mouse movements doesn't quite work out that well. It is lagging behind, heavily. So my question would be what's the appropriate ScreenCaptureKit methods to replace the functionality already created with CGWindowListCreateImage? Should I create a SCStream instead? Then I am worried about the fact that I would need to stream the whole screen instead of just the area around the mouse pointer since updating stream configs is an async function as well. I'd greatly appreciate any sort of direction!
1
2
1.2k
Oct ’23
Can anyone explain how buttonStyle works under the hood?
To make myself clear, I'm not asking how to use buttonStyle. I know that much. My question more lies in how does buttonStyle change the appearance of the button it's put on? So let's say I'm creating a custom component. I want that custom component to accept styles. Sure I could create an init that accepts a style but that doesn't feel very SwiftUI-ey. Instead, I want to be able to create a modifier that works similarly to the buttonStyle modifier. This is my desired outcome: CustomComponent() .customStyle(CustomComponentPlainStyle()) // where CustomComponentPlainStyle is any struct that conforms to CustomComponentStyle From my digging I discovered I have to somehow make use of a makeBody function that will create the desired look for the style from a given Configuration, not sure how to put all the pieces together though. Would apreciate any sort of direction! Cheers!
0
0
264
Nov ’23