[Feature] Interactive Liquid Glass: a view's glass that answers its presses (effectIsInteractive, isInteractive)

Aperta
#1,637 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
22/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
go, macos, objective-c
Ambito
desktop, mobile

Direzione di ricerca

Start with setBackdrop in internal/platform/macos/material.go, where the NSGlassEffectView gets its content view, and with hitTest in internal/platform/macos/macos.go (around lines 2457 and 2475) and the classOverlay hitTest: at line 566, which decide who receives presses. Done means a press on a glass-styled pressable view swells the glass and its OnPress still fires, with a native test covering the hit-view routing. The maintainer's three shape questions (boolean style, macOS-first scope, container children) need answers before implementation.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What you want to do / 想做什么

A button of Liquid Glass in an NSGo app stays still under a press, where the system's own controls of glass answer it. I would like a style that turns the system's answer on, for example Style.GlassInteractive bool beside GlassEffect (glassInteractive in TSX).

What the platforms have
  • macOS 27: NSGlassEffectView.effectIsInteractive (API_AVAILABLE(macos(27.0))): "should be enabled for glass that is used as the background for interactive controls or when used as the container of interactive controls".
  • iOS 26: UIGlassEffect.isInteractive.
  • Windows draws glass with NSGo's shader and the web a blur, so there is nothing to turn on there.
Why setting the property is not enough on macOS (main at a8284d7b)
  • setBackdrop (internal/platform/macos/material.go:175) puts the NSGlassEffectView under the view's children (line 208) and gives it glassContent, the border host, as its content view (line 220).
  • AppKit answers a press through a gesture recognizer on a private view inside the glass that holds the content view (NSGlassEffectView.ContentHolderView, an _NSComponentGestureRecognizer of SwiftUI's FlexInteraction). So it answers only when the view the press hits is the content view or a view inside it.
  • Measured on macOS 27.2.1 with raw AppKit views and the property set, by sampling the glass's presentation layers: a press on the bare glass, on a label in its content view, or on an NSButton in its content view scales the glass up by about 2.5 pt of width whatever its size (1.003× at 720 pt, 1.015× at 150 pt, 1.07× at 34 pt) and holds it there; on release it springs back while a second layer grows from 1.2× to 4× in about 0.6 s, which I take for the highlight. A press on a sibling view above the glass changes nothing.
  • NSGo's hit test returns the pressable view's own native view (hitTest, internal/platform/macos/macos.go:2457, return n at 2475), which is the glass's superview, and glassContent is a classOverlay, whose hitTest: returns nil (macos.go:566). With the property set, no press reaches the glass.
What worked in a fork, macOS only

On v0.2.0 plus a patch, on macOS 27.2.1:

  • The hit test returns the glass's content view for the presses the glass's own view takes (return n becomes that content view while the view's glass is interactive). AppKit sends the mouse events there, the content view handles none, so they go up the responder chain to the view's native view and mouseDown and mouseUp run as before. The content view answers acceptsFirstMouse: with true and mouseDownCanMoveWindow with false, as NSGo's views do.
  • A pressable view of glass then swells under the press and springs back, and its OnPress still fires. A native test covers the routing: the view hit is inside the glass's content view, its responder chain reaches the view, a pressable child keeps its own press, and turning the style off or taking the glass away gives the old hit view back. On main the border host is already there to take the presses.
  • The limit: a press a child takes, such as a button or a text field inside a container of glass, does not reach the glass, since NSGo's children are beside it. I tried making the holder of a view's children the content view. Every press was answered, but a multiline Input inside drew its caret 6 pt low, so I dropped it.
  • AppKit's answer is slight. Messages, a Catalyst app on UIKit's glass, swells far more under a press, so what the other targets imitate is a choice too.
Questions
  • Is a boolean beside GlassEffect the shape you want?
  • Should it wait for iOS, where the backdrop has setUserInteractionEnabled:false (internal/platform/ios/content.go:208) and touches need a way to the effect view, and for Windows' shader to imitate the swell, or can macOS go first with the rest in the roadmap?
  • Is "the presses the view takes itself" enough for a container, or should its children go inside the content view?

I can send the macOS part as a pull request once the shape is settled.

Target platforms / 目标平台

macOS, iOS

App language / 应用语言

Go

Latest version / 最新版本
  • I have checked that the latest NSGo release still lacks it. / 我已确认最新版 NSGo 仍不支持。
NSGo version / NSGo 版本

github.com/nsgo-dev/nsgo v0.2.0

Development machine / 开发环境

Arch Linux x86_64, Go 1.27.4, cross-building the macOS app; native tests on macOS 27.2.1 (Apple M3), Go 1.27.3, Command Line Tools 27.2

Target devices / 运行设备

Mac (Apple M3), macOS 27.2.1

Lingua principale
Go
Stelle
684
Fork
41
Merge medio
8h 8m
PR unite (30g)
911

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nsgo-dev/nsgo

Tutte le issue di nsgo-dev/nsgo

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.