question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Gestures receiving parameters and forwarding to a function

See original GitHub issue

Can I pass some object to the function inside of a gesture just like this? <StackLayout.GestureRecognizers> <TapGestureRecognizer Command="{Binding Source={x:Reference View}, Path=BindingContext.ItemTappedCommand}" CommandParameter="{Binding .}" /> </StackLayout.GestureRecognizers>

TapGesture in XAML

gesture in Fabulous gestureRecognizers =[ View.TapGestureRecognizer(command=(fun (param) -> dispatch PushPage ("ServantDetail",param))) ]

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
TimLarivierecommented, Mar 11, 2020

If you set the GestureRecognizer on the FlexLayout, you won’t be able to identify a specific child because you’re really listening for the FlexLayout.

What you can do though is to set one TapGestureRecognizer on each children.

children = [
    for i in servants do
        yield (servantImageFrame i.Image)
            .GestureRecognizers([
                View.TapGestureRecognizer(
                    command = fun () -> dispatch (PushPage i.Name) // here, you have access to the current item
                )
            ])
]

Better yet would be to pass your “page parameter” as a parameter to your servantImageFrame function so you can directly use gestureRecognizers in that function.

0reactions
luizhjcommented, Mar 11, 2020

Thank you @TimLariviere, it worked!

I changed the pushpage message type Msg = | PushPage of (string * Servant)

the update | PushPage (page,servant) -> { model with PageStack = Some page :: model.PageStack;Servant = servant}, Cmd.none

and the gesture for i in servants do yield (servantImage i.Image).GestureRecognizers([ View.TapGestureRecognizer( command = fun () -> dispatch (PushPage ("ServantDetail",i)) // here, you have access to the current item ) ])

Read more comments on GitHub >

github_iconTop Results From Across the Web

Forwarding a gesture to superview - ios
When you create your gesture, make the target the superview, and call the method in the superview for the action, something like:
Read more >
In SwiftUI, how can I perform a gesture but forward ...
Here is a demo of possible approach. Tested with Xcode 11.4 / iOS 13.4 struct ContentView: View { var body: some View {...
Read more >
Hand Gesture Controlled Presentation | OpenCV Python
Get Started with ClearML for free: https://clear.ml/ Download Code and Files: ...
Read more >
Use TalkBack gestures - Android Accessibility Help
TalkBack gestures help you navigate and perform frequent actions on your Android device. Single-finger & multi-finger gestures. Single-finger gestures are ...
Read more >
How Android 12 lets you control your phone with facial ...
These operations include: go to the next actionable screen object, select an object, go to the previous object, touch and hold, scroll forward, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found