Post

Replies

Boosts

Views

Activity

ScreenCaptureKit with dual monitors problem
I have a mac os app that uses screen capture logic. It was originally coded using the Quartz CG api: if let cgimage = CGDisplayCreateImage(CGMainDisplayID(), rect: cgRect) {...} and this worked as expected even when capturing a screen rect that began on secondary monitor and ended on primary monitor (or was entirely contained on secondary monitor). However now that API is deprecated and you're supposed to use ScreenCaptureKit instead. So I have attempted to convert the code. The trial code is: let scConfig = SCStreamConfiguration() scConfig.sourceRect = drect scConfig.width = Int(drect.width) scConfig.height = Int(drect.height) SCScreenshotManager.captureImage(contentFilter: sFilter, configuration: scConfig) {any,error in if let cgim = any { print("image dims \(cgim.width), \(cgim.height), requested: \(drect)") self.writeToFile2(cgim) } else { print("SCREEN CAP failed") } } ... where sFilter was previously set based on main screen display (with no exclusions). This code also "works" as long as the capture rect is entirely on primary monitor. But it fails if the rect spans both monitors or is fully contained on secondary monitor. (By fails I mean it produces empty image) So my question is: How to use ScreenCaptureKit to obtain screen shot of rectangle that spans dual monitors?
1
2
548
Jul ’24
SwiftUI app runs differently on hardware platforms
I have a simple SwiftUI app that has a picker, textfield and several buttons. It is using a Enum as a focus state for the various controls. When I compile and run it on Mac Studio desktop it works as expected: Picker has initial focus, Selection in Picker changes focus to TextField, Tab key moves through buttons; last button resets to Picker However when I run the exact same app on MacBook Pro (same version of MacOS, 14.5) it does not work at all as expected. Instead: Initial focus is set to TextField, Tab does not change the focus, Clicking on last button resets focus to TextField rather than Picker The content view code: enum FFocus: Hashable { case pkNames case btnAssign case tfValue case btn1 case btn2 case noFocus } struct PZParm: Identifiable { var id = 0 var name = "" } struct ContentView: View { @State var psel:Int = 0 @State var tfVal = "Testing" @FocusState var hwFocus:FFocus? var body: some View { VStack { Text("Hardware Test").font(.title2) PPDefView(bSel: $psel) .focused($hwFocus, equals: .pkNames) TextField("testing", text:$tfVal) .frame(width: 400) .focused($hwFocus, equals: .tfValue) HStack { Button("Button1", action: {}) .frame(width: 150) .focused($hwFocus, equals: .btn1) Button("Button2", action: { tfVal = "" hwFocus = .tfValue }) .frame(width: 150) .focused($hwFocus, equals: .btn2) Button("New", action: { tfVal = "" hwFocus = .pkNames }) .frame(width: 150) .focused($hwFocus, equals: .btnAssign) } } .padding() // handle picker change .onChange(of: psel, { if psel > 0 {hwFocus = .tfValue} }) .onAppear(perform: {hwFocus = .pkNames}) } } #Preview { ContentView() } struct PPDefView: View { @Binding var bSel:Int // test defs let pzparms:[PZParm] = [ PZParm.init(id:1, name:"Name1"), PZParm.init(id:2, name:"Name2") ] // var body:some View { Picker(selection: $bSel, label: Text("Puzzle Type")) { ForEach(pzparms) {Text($0.name)} }.frame(width: 250) } }
3
0
771
Jun ’24
Show Table in SwiftUI Playground
I am trying to generate a simple playground to display Table structure with several TableColumns. Basically, generated a new blank playground; add import statements for SwiftUI and PlayGround support; add structure for content view and a statement for invoking that view as: `PlaygroundPage.current.setLiveView(ContentView()) In general, all of the view components work as expected EXCEPT for the table structure which does not display anything. Its basic structure is: Table(rows, selection: $selRow) { TableColumn("ID") {Text(String($0.id))} TableColumn("Name", value: \.nt) } where "rows" is an array of the structure TRow: struct TRow : Identifiable { var id:Int var num:Int var nt:String } Is there some special trick to allowing a SwiftUI Table to be displayed in Playground?
1
0
603
Dec ’23
Studio Display Firmware 17
I have Mac Sonoma beta installed on an external hard drive; when I boot into it I get a notification that there is an update for Apple Studio display (17..0). This update is NOT available when booted into Mac OS 13.4 so I am hesitant to apply it through Sonoma. Question is: will installing this update while in Sonoma cause issues when Studio Display is used in 13.4?
2
0
544
Jul ’23
Macos 14 Sonoma install problem
I am trying to upgrade to Sonoma; it shows in System Settings Software update and when I click on "upgrade" it downloads the install program and "installs" it but when computer reboots it still has older version. (System settings still shows upgrade available). Is there a way to figure out why the install failed?
1
0
787
Jun ’23
scroll to selected SwiftUI table row after sort
I'm using TABLE in SwiftUI macOS app with several Table Columns: each column has an associated sort key. The sorting works fine but my question is: If the table supports single row selection, is there a way to scroll to the selected row after a sort operation? EG if I have 300 rows and only 50 display at a time if row 5 is selected and column sorting moves this row to row 200 how can I scroll to row 200 after sort? I have seen examples of using LIST and ScrollViewReader to programmatically scroll to a LIST row but this approach does not appear to work with TABLE structures.
0
1
562
Jul ’22
Network TCP total length
I am testing a simple TCP server/client app using the Network support on mac os x. It basically works well except when the server sends a lot of data (definition of "a lot" is that the amount of data exceeds the maximumLength value in the connection.receive call). In this case the client will receive multiple segments (each of which has less than or equal maximumLength value). For example if the maximumLength is set to 30000 and the server sends 100000 bytes, the client receive loop will get around 4 segments each of which has length <= 30000. My question is: is there some information that the client can examine from the connection after a receive to determine that more data is available?
1
0
508
Jun ’22
Frame auto save in SwiftUI App
I have a simple SwiftUI app with a Settings View. When the view is displayed (via Preferences menu item) I move it to a different screen position. After ending the app and re-starting it, the Settings View is displayed at original position rather than new position. If I look at the default preferences for the app, there is an entry for: "NSWindow Frame com_apple_SwiftUI_Settings_window" which has the modified screen position but it appears that the app does not use this position when displaying Settings View. Is there some other way to assign Settings window position?
0
0
604
Jan ’22
App no longer run on Monterey 12.0.1
Some of my apps no longer run in Monterey 12.0.1; they abort with dylib error such as: Library not loaded: @rpath/SwiftSocket.framework/Versions/A/SwiftSocket . . . (no such file) the library is located in ~/Library/Frameworks and this worked in earlier versions of mac os x but now fails. If I copy the framework to /Library/Frameworks then the apps execute as expected. How can I set the runtime search path properly when building the project in Xcode 13.1?
1
0
1.1k
Oct ’21
NSTableView height
I have (what I thought was) a very simple mac OS project view consisting of a window, a tabbed view with 2 tabs and in one of these tabs a tableview. When I run it it works as expected; however sometimes the datasource contains more rows than will display; in this case the vertical scroll works fine. I can drag the window frame to "resize" the window but the tableview height does not change. To fix this problem I added 2 constraints to the border scroll view of the table - for top space and bottom space - both set relative to its superview. The top space is set to a fixed value and the bottom space is set to "default". When I do this there are no layout constraint errors but when I run it, the table doesn't appear at all. Any thoughts or suggestions?
3
0
1.1k
May ’21
Xcode 12 ML Model Compatibility
I have a simple app built with Xcode 11.7; it uses 2 ML Models that were generated with Create ML tool. It builds and executes as expected. After installing Xcode 12, when I try to build the app (without any changes), I get build failures with a message like this: Type 'MLModel' has no member '__loadContents' it appears twice (presumably once for each ML Model). I tried re-generating the ML models with Create ML from Xcode 12 but that didn't eliminate the error messages. (If I do a CLEAN-PROJECT before building, still get the errors) (Also, the Xcode 11.7 app still executes without problems) Anyone else have this type of problem?
7
0
1.9k
Sep ’20
Revoked Certificate
Every 24 hours or so I get this email: "You have revoked your certificate, so it is no longer valid". What did I do to revoke it? (I"m just using the Xcode auto-generation process so unsure as to what I did that caused it to be revoked). It doesn't seem to have any effect on testing but it's annoying to constantly get this email, so I'm just trying to understand why this keeps happening. Are these Xcode generated certificates only valid for 24 hours?
3
0
7.2k
Feb ’20