I’ve looked at another post here on Stack Overflow concerning the back gesture, but mine is a little different.
How can I implement the swipe gesture to go ‘Back’ and ‘Forward’, to have an effect on the WebView the cursor is over? For example, if there are more than one, the gesture goes to and affects the appropriate view.
I suppose it would be the following code, but I do not know how to get the gesture methods to work:
- (void) backGesture {
[(WebView *)self.theWebView goBack];
}
- (void) forwardGesture {
[(WebView *)self.theWebView goForward];
}
Where ‘theWebView’ is the WebView the cursor is hovered over.
Is this even possible?
Well, you could add a category to webView with a swipeWithEvent methd, so that each view handles its own swipe (the three-finger variety; the two-finger scrolling is translated into mouse actions for the webview).
WebView+addSwipe.h:
WebView+addSwipe.m:
And, if you WERE on iOS, attach two UISwipeGestureRecognizers to each view; one for each direction with separate actions:
with your viewController as the target. Each gesture action will be handed a sender, so sender.view will tell you which view had the swipe in it.
Note that “Three Finger Swipe to Navigate” must be on in Trackpad control panel on the system your program is running on.