Questions tagged [nsviewrepresentable]

24 questions
0
votes
1 answer

Change NSTextField text color when in edit mode

Using NSTextField I'd like to change the text color from black to white when going into edit mode. Right now, it: Defaults to black when not selected (GOOD) Defaults to white when selected (GOOD) Changes color to black when editing starts…
MMV
  • 297
  • 2
  • 9
0
votes
0 answers

Why does all formatting disappear from an NSTextView when using NSViewRepresentable and SwiftUI?

I am making a small program using SwiftUI that allows users to create rich text "notes" in an NSTextView. I have enabled all of the formatting features from NSTextView, including the ability to work with images. The program is only for macOS and not…
0
votes
0 answers

How to open and configure a new Window in SwiftUI?

I want to create a web browser that if a link opens in a new window it will open a new window (tab) with the new link. struct WebBrowserApp: App { var body: some Scene { WindowGroup { ContentView() } } } struct…
Mark
  • 16,906
  • 20
  • 84
  • 117
0
votes
1 answer

SwiftUI get NSViewRepresentable to automatically redraw

I have introduced a styled NSViewRepresentable text field on to my layout in order to use an attributed Text Editor field. I want to influence the content of this text field through some buttons. I can change the styled attributes of the field, but…
iphaaw
  • 6,764
  • 11
  • 58
  • 83
0
votes
1 answer

SwiftUI Binding Edits Wrong TextField after Item Reordered

Xcode 13 beta 5, iOS 14, macOS 11.6 I have a parent SwiftUI view that lists some children. Each child is bound to an NSViewRepresentable. Everything works and I can edit the values as expected. But once I reorder the items in the list and edit a…
Clifton Labrum
  • 13,053
  • 9
  • 65
  • 128
0
votes
2 answers

What wiring code is necessary to wrap NSComboBox with NSViewRepresentable?

I am trying to wrap NSComboBox with NSViewRepresentable for use in SwiftUI. I would like to pass in both the list of dropdown options and the text value of the combo box as bindings. I would like the text value binding to update on every keystroke,…
kamcma
  • 203
  • 3
  • 5
0
votes
1 answer

How to Change NSTextField Font Size When Used in SwiftUI

Below is a demo app with a simple NSTextField in a Mac app. For some reason, the font size won't change no matter what I try. import Cocoa import SwiftUI @main struct SwiftUIWindowTestApp: App { var body: some Scene { WindowGroup { …
Clifton Labrum
  • 13,053
  • 9
  • 65
  • 128
0
votes
1 answer

Cannot find type 'NSViewRepresentable' in scope

I want to create a blurred view in SwiftUI using NSViewRepresentable but XCode gives me an error message that says "Cannot find type 'NSViewRepresentable' in scope". import SwiftUI struct BlurWindow: NSViewRepresentable { //Cannot find type…
SmoothPoop69
  • 160
  • 3
  • 8
0
votes
0 answers

Pass values from NSTextView to parent SwiftUI View via NSViewRepresentable when selection changes

Problem I want to be able to pass the text attributes from the selected range of the textView.textStorage and/or the typing attributes from the textView. This should happen when the selection changes. The goal of this is so that the SwiftUI view can…
santi.gs
  • 514
  • 3
  • 15
1
2