SwiftUI - Make Grid row selectable including the text? - Stack Overflow
In a grid View, here a LazyVGrid
, I understand that to make a row "tappable" one should add the .contentShape()
modifier with a Rectangle()
shape:
LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible())]) {
Text("first column")
Text("second column")
// potentially many columns
}
//.overlay(content: { Rectangle().fill() })
.contentShape(Rectangle())
.onTapGesture {
print("row tapped")
}
However, while the space in the row is now tappable, clicking on the text is not recognized as a tap. The text is selectable for copying because I have .textSelection(.enabled)
on its container.
Is there a way to make the text tappable as well?
And can that be achieved while allowing it to still be selectable?
- I have found that using an
overlay
with a filled Rectangle works, but not if thefill
isColor.clear
. - I saw an idea to
fill
with UIColor of System background, but I would rather not import UIKit. - I saw the idea of using a fill with
opacity
so little that it was not apparent to the user. Is that really the only way to do it? (Also the text is no longer selectable.)
最新文章
- 有事请烧纸!清明祭奠已死的平板电脑
- Docker environment for aya rust ebpf compilation - Stack Overflow
- Unable to Access Event Data via Eventbrite API - 404 NOT_FOUND Error - Stack Overflow
- swiftui - Previewing SwiftData Records in Xcode Previews - Stack Overflow
- asp.net - Razor Pages 'asp-page-handler' did not working [POST] - Stack Overflow
- grpc - In gNMI, What's the difference between the "Origin" that can be specified in a path and &qu
- reactjs - how to fetch headers in middleware in Next js - Stack Overflow
- javascript - MineFlayer bot Error: read ECONNRESET as I was trying to log it in to my server - Stack Overflow
- reactjs - why react dev tools paint highlights to components in this example - Stack Overflow
- node.js - Push notification not getting delivered - Stack Overflow
- python - Tkinter: custom frame widget overrides columnconfigure - Stack Overflow
- caching - How is the userUX affected by cache purge by a WordPress plugin? Cookie consent settings is not affected? - Stack Over
- javascript - How to Retrieve Logs from %temp%OfficeAddins.log.txt and Display Them in an Excale Add-in Side Panel - Stack Overfl
- python - overrideredirect() no longer working on MAC? - Stack Overflow
- ios - SwiftUI TextField with UIKit wrapper expanding full screen when entering numbers in custom crypto swap interface - Stack O
- angularjs - how to display a pdf in angular? - Stack Overflow
- Is there showhide functionality for boiler plate content in google docs? - Stack Overflow