Post

Replies

Boosts

Views

Activity

Getting WKWebView to not NSBeep on every key
I have a webpage that needs to receive keypresses to zoom and scroll. This seems to be the only way to prevent the annoying NSBeep from occurring. Return true too much, and command keys stop working. So need to be explicit about which keys you want. Also no way to block delete/shift+delete from going fwd/back in the history using this same mechanism. func isKeyHandled(_ event: NSEvent) -> Bool { // can't block delete or shift+delete // so the WKWebView goes back/foward through it's 1 page history. // that loses all context for the user. // prevent super annoying bonk/NSBeep // if don't check modifier flags (can't check isEmpty since 256 is often set // then the cmd+S stops working if !(event.modifierFlags.contains(.command) || event.modifierFlags.contains(.control) || event.modifierFlags.contains(.option)) { // wasd if event.keyCode == Keycode.w || event.keyCode == Keycode.a || event.keyCode == Keycode.s || event.keyCode == Keycode.d { return true } } return false } // Apple doesn't want this to be overridden by user, but key handling // just doesn't work atop the WKWebView without this. KeyUp/KeyDown // overrides don't matter, since we need the WKWebView to forward them override func performKeyEquivalent(with event: NSEvent) -> Bool { if !isKeyHandled(event) { return super.performKeyEquivalent(with: event) } return true }
0
0
498
Mar ’24
Why doesn't XCode AVX2 setting set -mf16c and -mfma
There's nowhere to add -mf16c and -mfma that doesn't cause a uinversal build to spew warnings about those settings when it builds arm64. I'd rather not have to add a xcconfig file across every project with an x64 specific setting. So why doesn't the AVX2 setting (-mavx2) also set these flags? -mhaswell does, and so does -mx86-64-...-v3, but those seem to only be supported by clang-cli on Windows.
0
1
353
Oct ’24
Getting stuck in first frame of renderLoop.
First I get this ar_world_tracking_provider_query_device_anchor_at_timestamp <0x302b9c0a0>: The device_anchor can only be queried when the world tracking provider is running. This seemed to all break with the auto-update to 2.0.1. Simulator runs the code fine. I seem to see an infinite stall here frameLayer.endUpdate() // Pace frames by waiting for the optimal prediction time. try await LayerRenderer.Clock().sleep(until: timing.optimalInputTime, tolerance: nil) // Start submitting the updated frame. frameLayer.startSubmission() <-
0
0
526
Oct ’24
How to enable Rez in Xcode 12.2
The Adobe C++ plugin SDK are still using Rez to compile resources on macOS and winOS. But Rez build settings are missing from my newly created project. They exist in a legacy project. How does one re-enable this functionality. I don't know that Apple has offered an alternative to file-based resource generation, so removing this functionality seems premature. The help and man pages on Rez are missing a lot. What to supply for arch (x86_64)? Why do I have to supply the framework path to Xcode to find Carbon.r and CoreServices.r? Rez itself provides only the barest of command line usage details. For example, I couldn't get .r includes to work with -i or -s, but it works with -I. But the resulting .rsrc file that is generated by my command line efforts is 0 sized. The one built from Xcode is 1.5KB (correct). Also SIP was blocking all attempts to debug these plugins, but a workaround was found for that.
1
1
1.5k
Mar ’21
xcodebuild clean fails with CMake and custom build directories on new build system
CMake calls through to xcodebuild clean, but this fails since custom build directories are set. The current workaround is to have to trash the entire CMake build folder. With many subprojects this then takes a long time to rebuild. Can Apple please fix this? Here I have a project with multiple targets (a fake workspace). CMake can only generate xcprojects and not xcworkspace files. Visual Studio and Android Studio both integrate CMake into the IDE. But building iOS and macOS universal apps is still not simple with CMake. Can Xcode team support CMake better in general? cmake --build . --target clean  xcodebuild -project foo.xcodeproj clean -target ALL_BUILD -parallelizeTargets -configuration Debug -hideShellScriptEnvironment Command line invocation:   xcodebuild -project foo.xcodeproj clean -target ALL_BUILD -parallelizeTargets -configuration Debug -hideShellScriptEnvironment User defaults from command line:   HideShellScriptEnvironment = YES note: Using new build system note: Building targets in parallel error: Could not delete `build/lib` because it was not created by the build system. error: Could not delete `build/app1` because it was not created by the build system. error: Could not delete `build/app2` because it was not created by the build system. warning: Refusing to delete `build` because it contains one of the projects in this workspace: `build/foo.xcodeproj`. CLEAN FAILED
1
0
3k
Sep ’21
readFromURL only called once on NSDocument-based app for each "Open Recent" menu item
I have a single-windowed app that loads textures. I want to be able to switch textures to anything in the Open Recent menu item list that I add URLs into. When I launch the app, each recent menu item calls readFromURL once. But subsequent selection of the menu item does not. I can see the documents in the document controller increasing, so I know that is likely why this callback isn't called. If I return NO from readFromURL then it is called every time, but posts a dialog about the file failing to load. I want that behavior, but not the dialog. I'm not really using the NSDocuments created, but I needed this mechanism to get at the URL to load the data. I can't really remove documents from list, so I just let them accumulate but they basically just store the URL. What am I supposed to hook as a callback? Is there a switchToDocument callback hook/delegate?
Topic: UI Frameworks SubTopic: AppKit Tags:
1
0
639
May ’21
ModelIO primitives undocumented and inconsistent.
There are no images on the basic primitives used in ModelIO that I've found so far. If these primitives are meant to be used by apps as starter content, then they should follow consistent modeling and uv wrapping rules. The sphere has uv coordinates where the u direction wraps counterclockwise. The capsule has the same problem. This is the opposite of the cube which fits u clockwise on each face. Solution was to flip x with 1-uv.x. The sphere reports 306 vertices on latest Big Sur, but after vertex 289 the rest of the vertex data is garbage data. The uv seam on the sphere is rotated by -45 degrees from the capsule. I had to flip the bitangent sign too in my app. This seemed to be reversed, but could be from shader issues. On my MBP 16" I'm getting uv's that are non-zero, but all zero derivatives. I don't know yet if this is from 2. Here's part of what I did to fix the mesh. This doesn't include the call to generate tangents and bitangent sign, and then flip the sign. mdlMesh = [MDLMesh newEllipsoidWithRadii:(vector_float3){0.5, 0.5, 0.5} radialSegments:16 verticalSegments:16 geometryType:MDLGeometryTypeTriangles inwardNormals:NO hemisphere:NO allocator:_metalAllocator]; float angle = M_PI * 0.5;   float2 cosSin = float2m(cos(angle), sin(angle));       {     mdlMesh.vertexDescriptor = _mdlVertexDescriptor;           id<MDLMeshBuffer> pos = mdlMesh.vertexBuffers[BufferIndexMeshPosition];     MDLMeshBufferMap *posMap = [pos map];     packed_float3* posData = (packed_float3*)posMap.bytes;           id<MDLMeshBuffer> normals = mdlMesh.vertexBuffers[BufferIndexMeshNormal];     MDLMeshBufferMap *normalsMap = [normals map];     packed_float3* normalData = (packed_float3*)normalsMap.bytes;           // vertexCount reports 306, but vertex 289+ are garbage     uint32_t numVertices = 289; // mdlMesh.vertexCount           for (uint32_t i = 0; i < numVertices; ++i) {       {         auto& pos = posData[i];                 // dumb rotate about Y-axis         auto copy = pos;                   pos.x = copy.x * cosSin.x - copy.z * cosSin.y;         pos.z = copy.x * cosSin.y + copy.z * cosSin.x;       }               {         auto& normal = normalData[i];         auto copy = normal;         normal.x = copy.x * cosSin.x - copy.z * cosSin.y;         normal.z = copy.x * cosSin.y + copy.z * cosSin.x;       }     }           // Hack - knock out all bogus vertices on the sphere     for (uint32_t i = numVertices; i < mdlMesh.vertexCount; ++i) {       auto& pos = posData[i];       pos.x = NAN;     }           }
1
0
701
Jun ’21
QuickLook preview never displays NSImageView
I have an NSImageView-based preview appex plugin for macOS in Objective-C. It's based off the sample template that you can add to an app. It completely makes it through preparePreviewOfFileAtURL, and I stuff pixel data into a CGImage, then that into an NSImage and that onto an NSImageView that is self.view from the storyboard. I can see all data via qlManager -p, since it will print error messages for caveman debugging. I have no idea and there are no docs on using the "Quick Look Simulator" which appears to do nothing. I set background color of the NSImageView.layer to red, and it shows up red. So I know the NSImageView is visible, just not the image that it also points to. About 30% of the time, only the red shows up, and the other 70% of the time nothing shows up in preview just smokey blurred version of the icons underneath in Finder. My only recourse, is to disable the extension list for the preview appex, and let the thumbnailer appex provide the preview. There are no samples of this for macOS, and the default templates aren't a working version of this either.
1
0
805
Feb ’22
NSTableView doesn't gap vertically from top
I have an scrolling NSTableView that has an isFlipped MTKView as the parent. No matter how I set the growth constraints, frame.y (which seems to offset from bottom left still) or adjust the height, I can't get a gap from the top. I have a hud that this then clobbers over. I want to offset from the top-left so this doesn't happen. What is the magic to do this?
Topic: UI Frameworks SubTopic: AppKit Tags:
1
0
667
May ’22
Metal compiler fails on valid usage of depth2d<half> references
I'm working on a parser which translates HLSL to HLSL/MSL. But valid MSL isn't compiling when passing the depth2d to a class and class ctor. The ctor use allows globals to be referenced as member variables by the MSL which typically passes it's parameters from call to call. This reports the following which makes no sense. The code is fine with use of texture2d and references, so seems to be a metal compiler bug. It's saying the ctor input needs to be device space, but it's already decleared as such. This limits any use of depth style textures in MSL. DepthTest.metal:31:16: error: no matching constructor for initialization of 'SamplePSNS'   SamplePSNS shader(shadowMap, sampleBorder);         ^   ~~~~~~~~~~~~~~~~~~~~~~~ DepthTest.metal:18:5: note: candidate constructor not viable: address space mismatch in 1st argument ('depth2d<float>'), parameter type must be 'device depth2d<float> &'   SamplePSNS(   ^ DepthTest.metal:5:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided struct SamplePSNS {     ^ DepthTest.metal:5:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided #include <metal_stdlib> using namespace metal; struct SamplePSNS {   struct InputPS {     float4 position [[position]];   };       device depth2d<float>& shadowMap;   thread sampler& sampleBorder;       float4 SamplePS(InputPS input) {     return shadowMap.sample_compare(sampleBorder, input.position.xy, input.position.z);   };       SamplePSNS(    device depth2d<float>& shadowMap,    thread sampler& sampleBorder)     : shadowMap(shadowMap),      sampleBorder(sampleBorder)   {} }; fragment float4 SamplePS(   SamplePSNS::InputPS input [[stage_in]],   depth2d<float> shadowMap [[texture(0)]],   sampler sampleBorder [[sampler(0)]]) {   SamplePSNS shader(shadowMap, sampleBorder);   return shader.SamplePS(input); }
1
0
700
Mar ’23
HDR seems broken for iOS on macOS using M2 MBP.
Trying to test HDR running an EDR-capable iOS app on macOS. This is running on the same M2 MBP. On macOS, NSScreen.maximumPotentialExtendedDynamciRangeColorComponentValue returns 16. That's what I'd expect on a mini-led display like this one. On iOS on macOS, UIScreen.potentialEDRHeadroom reports 1.0. That's not correct.
1
0
807
Jun ’23
AppKit does not allow directory to be selected
I have a UTI for "public.directory" and can drag-drop folders onto my app and open them. I also added this to the Info.plist to say the app supported directoryies. But the default "Open" command seems to popup up an NSOpenPanel with folders not selectable. The "Open" button stays disabled. How do I change this? I tried implementing "openDocument", but then it lets through any file type, not just the ones in my Info.plist. So I'd like to just use the default implementation, but need an override for the NSOpenPanel. (IBAction)openDocument:(id)sender { NSOpenPanel *panel = [NSOpenPanel openPanel]; [panel setCanChooseFiles:YES]; [panel setCanChooseDirectories:YES]; [panel setAllowsMultipleSelection:NO]; ... }
Topic: UI Frameworks SubTopic: AppKit Tags:
1
0
584
Oct ’23
WKWebView changes page off "delete" key
I have the following set, but the WKWebView is losing the page content that I'm updating in a given page whenever the user presses the "delete" key. This is in SwiftUI, and I see no way to intercept and block this key. webView.allowsBackForwardNavigationGestures = false Isn't the whole point of setting this flag, to not just have "swipe" navigation stop, but all back/forward support stop? Also with the backForwardList immutable, it's not like I can delete an entry from it.
1
0
628
Mar ’24