Parameter update from NSView (right click in MacOS SwiftUI)

While function calls work as expected in an NSViewRepresentable, I'm unclear why the parameter passed below (to show a SwiftUI popup) does not update after a function call in the NSView. Any tips?

Some View Struct
Code Block swift
@State var showMenu = false
var body: some View {
ZStack {
RightClickableSwiftUIView(onClick: $showMenu)
Image(name)
.popover(isPresented: $showMenu, ...)
}
}


RightClick.swift
Code Block swift
import SwiftUI
struct RightClickableSwiftUIView: NSViewRepresentable {
@Binding var onClick: Bool
func updateNSView(_ nsView: RightClickableView, context: NSViewRepresentableContext<RightClickableSwiftUIView>) {
}
func makeNSView(context: Context) -> RightClickableView {
RightClickableView(onClick: $onClick)
}
class RightClickableView : NSView {
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
init(onClick: Binding<Bool>) {
_onClick = onClick
super.init(frame: NSRect())
}
@Binding var onClick: Bool
override func mouseDown(with theEvent: NSEvent) {
print("left mouse")
}
override func rightMouseDown(with theEvent: NSEvent) {
onClick = true
print("right mouse")
}
}
}


This is related to another user's post:
https://developer.apple.com/forums/thread/127921

Answered by wingover in 622339022
Oh egads that's embarrassing. The class was in the struct, so of course the Binding didn't update.
Accepted Answer
Oh egads that's embarrassing. The class was in the struct, so of course the Binding didn't update.
Parameter update from NSView (right click in MacOS SwiftUI)
 
 
Q