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

オープン
#1,637 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
22/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
go, macos, objective-c
領域
desktop, mobile

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Go
スター
684
フォーク
41
平均マージ
8時間 8分
マージ済み PR(30日)
911

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nsgo-dev/nsgo のほかの issue

nsgo-dev/nsgo の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。