Post

Replies

Boosts

Views

Activity

Reply to Detecting tap on tvOS with SwiftUI
you can detect press or long press while using focusable, like this: import SwiftUI struct TestView: View {   @State var isFocused: Bool = false       var body: some View   {     Button(action: {       print("Clicked") // simple click     }, label: {       Text("Click Me")     })           .buttonStyle(PlainButtonStyle())           .focusable(true, onFocusChange: { focused in       self.isFocused = focused     })           // long press (hold for at least half a second)     .highPriorityGesture(       LongPressGesture(minimumDuration: 0.5)         .onEnded { _ in           print("Long Pressed ...")         }     )           // click     .onLongPressGesture(minimumDuration: 0.01, perform: {       print("Single Short Click Pressed ...")     })   } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’22
Reply to tvos 15 - Siri Remote not returning in the array: GCController.controllers()
thanks @robnotyou based on your answer i added a first call and the second call (after interaction with remote) worked on first call: import GameController struct ContentView2: View {   var body: some View {     let a = print("controllers: \(GCController.controllers())")           Button("Query controllers") {       print("controllers: \(GCController.controllers())")     }   } } i think there is some initialization missing (dam apple and it's useless docs) for now this workaround will do
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’21
Reply to Detecting tap on tvOS with SwiftUI
you can detect press or long press while using focusable, like this: import SwiftUI struct TestView: View {   @State var isFocused: Bool = false       var body: some View   {     Button(action: {       print("Clicked") // simple click     }, label: {       Text("Click Me")     })           .buttonStyle(PlainButtonStyle())           .focusable(true, onFocusChange: { focused in       self.isFocused = focused     })           // long press (hold for at least half a second)     .highPriorityGesture(       LongPressGesture(minimumDuration: 0.5)         .onEnded { _ in           print("Long Pressed ...")         }     )           // click     .onLongPressGesture(minimumDuration: 0.01, perform: {       print("Single Short Click Pressed ...")     })   } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to tvos 15 - Siri Remote not returning in the array: GCController.controllers()
thanks @robnotyou based on your answer i added a first call and the second call (after interaction with remote) worked on first call: import GameController struct ContentView2: View {   var body: some View {     let a = print("controllers: \(GCController.controllers())")           Button("Query controllers") {       print("controllers: \(GCController.controllers())")     }   } } i think there is some initialization missing (dam apple and it's useless docs) for now this workaround will do
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21