Post

Replies

Boosts

Views

Activity

Setting attributed title to tab doesn't work in Document Based App
Hi, I'm working on making a Document based app for MacOS using AppKit and I wanted the different documents to be displayed as tabs of the same window which after a lot of research I managed to do using this single line: windowController.window?.tabbingMode = .preferred which I added inside the makeWindowControllers function of my Document. I figured that in order to be able to style my tabs I should use this method: windowController.window?.tab.attributedTitle = ... But whatever I added after this = didn't do anything to my tabs. For example I tried this: windowController.window?.tab.attributedTitle = NSAttributedString(string: "Hello", attributes: [NSAttributedString.Key.backgroundColor: NSColor.red]) Weirdly, using this method: windowController.window?.tab.title = ... did work but is far more limited than the other one. Maybe I did something wrong in my implementation of the tabs but it seems to work properly when I run it, only the colors and fonts don't match what I'd like to make which is why I wanted to change them using the attributed title. Here's my full code for the function: override func makeWindowControllers() {     let storyboard = NSStoryboard(name: NSStoryboard.Name("Main"), bundle: nil)     if let windowController =         storyboard.instantiateController(             withIdentifier: NSStoryboard.SceneIdentifier("Document Window Controller")) as? NSWindowController {         addWindowController(windowController)         windowController.window?.tabbingMode = .preferred         windowController.window?.tab.attributedTitle = NSAttributedString(string: "hey", attributes: [NSAttributedString.Key.backgroundColor: NSColor.red])         // Set the view controller's represented object as your document.         if let contentVC = windowController.contentViewController as? ViewController {             contentVC.representedObject = content             contentViewController = contentVC         }     } } I would really appreciate some help on this issue! Thanks by advance, Cyprien
2
0
1k
Jun ’22
Two NSTextView inside the same NSScrollView
Hello, I am currently trying to implement an NSScrollView containing 2 NSTextView using the Storyboard in Xcode. I found the NSScrollView and a NSTextView inside a NSScrollView in the element library (pictures below) But I haven't found a way to add another NSTextView inside any of them, the NSTextView can't even be found in the element library. Maybe there's something I am missing or don't know. I would really appreciate some help since I haven't found any while searching on existing questions. Thanks in advance, Cyprien
3
0
819
Oct ’21
Destecting double tap on Apple Pencil with SwiftUI
Hello, I am making an app for iPad and I would like to be able to detect when the Apple Pencil is double tapped with my SwiftUI (I am not using PencilKit because I'm not making a drawing app). I saw it was possible with UIKit but didn't quite understand if I could use UIKit functions on SwiftUI. I just want to perform some action when the Pencil is double tapped, very basic. If anyone could help me I would really appreciate it ! Thanks by advance, Cyprien
2
0
1.3k
Nov ’20
Detect a lamp that turn on and off with the camera
HelloI'd like to do an app in Swift that allows me to detect a morse code with the camera, I mean, if you point the camera on a lamp that turn off and on, the app will detect the morse code and translate it to english or other language. It's like a qr reader but with light's flashes.I've got some basics in Swift but I have no idea on how I should do it and I already searched on the Internet without success.I think I should do a target/point that the user will have to point and the app will detect a color change on the target but I don't know how to do it.Thanks for your help.SigmaPS: Sorry if there are some mistakes I'm not English ...
5
0
3.3k
Sep ’17