Trackpad gestures & Scrollwheel head scratching

My apps have been around a while.
Before iPhones certainly.

People have laptops with trackpads, and the trackpads now emulate gestures like those on the phones.
How can I make a window react to 2-finger drag/scroll and pinch/zoom gestures?
Mac and Windows

Drag/scroll with two fingers should be transparent and seen like MouseWheel.

At least, that is my experience on Mac. I would be surprised if it was different on Windows.

It appears that it is, and so was I.
I’ll do some digging - I do have the Mousewheel event defined.

Pinch zoom… ??

It requires some hacking to get the other gestures, I wrote an article for xDev 14.5 on how you can accomplish this.

http://xdevmag.com/

Bought that. Thanks Sam.
Going to be …interesting… getting that to work. :slight_smile:

On WIndows, dont seem to have anything.

Mousewheel seems odd… Obviously if you scroll the wheel, you expect up/down to happen.
I added a CTRL modifier so that it will operate zoom too.
Is there a convention for using the scrollwheel to move left/right?

Also on Windows:
I have a Dell laptop.
Two finger drag works (poorly) for up and down… even with no code it seems to activate a vertical scrollbar on my window.
Two finger drag works terribly for left/right… the horizontal scrollbar just wanders around as if drunk.
And pinch/zoom does nothing … I have no way to detect it.

https://msdn.microsoft.com/en-us/library/windows/desktop/dd940543(v=vs.85).aspx

MBS Plugin has classes to do this on Mac and Windows.

So I hear, and I have the plugins.
But I cannot understand the documentation:

https://www.monkeybreadsoftware.net/class-wingestureconfigmbs.shtml

Did you try an example project?

I cannot find examples in the examples folder, mainly because I cannot work out what they might be called or which folder they might be in.

The documentation page lists the example on the bottom:

/Win/Windows Touch Events

Touch events = trackpad?
Are there Mac equivalents?

for Windows the relevant classes are here:

http://www.monkeybreadsoftware.net/pluginpart-winnotification.shtml

We can catch gestures and pointers, whether it’s touch screen or trackpad.

For Mac, you find the gesture event on various classes and controls:

event beginGestureWithEvent(e as NSEventMBS) as boolean
event endGestureWithEvent(e as NSEventMBS) as boolean
event swipeWithEvent(e as NSEventMBS) as boolean
event magnifyWithEvent(e as NSEventMBS) as boolean
event rotateWithEvent(e as NSEventMBS) as boolean

e.g. on NSViewControlMBS control or CustomNSViewMBS class,

Thanks Christian.
Has anyone (else) managed to make these work?

Perhaps I am having a ‘stupid’ weekend but I cant see anything except a list of event names in these documents or projects.
Nothing to tell me ‘how’ to make them work on my projects, just a list of available events, and a log saying that an event has fired.

:frowning:

CustomNSView to capture gestures.xojo_binary_project does not run (mac)
“CocoaControlMBS1 implements GetView but…”

Which version of Xojo do you use with which version of the MBS plugins? 2017r3/MBS 22.01.2018 runs fine here. That the gestures themselves don’t work is another problem. I have a Wacom tablet that should recognize at least some gestures.

On Mac, I opened this sample project in Xojo 2015 R3 with plugins 18.1
The example code appears unchanged since 2012

Cut down a little, it is:

[code]This example is the version from Tue, 29th Oct 2012.
Project “CustomNSView to capture gestures.rbp”
//===
Class Window1 Inherits Window
Control CocoaControlMBS1 Inherits CocoaControlMBS
ControlInstance CocoaControlMBS1 Inherits CocoaControlMBS

// THIS IS THE PART WHICH WONT COMPILE
// What triggers a GetView() event?
// What handles the returned myView object?

		EventHandler Function GetView() As NSViewMBS    
			n = new MyView
			
			Return n
		End EventHandler

//========================

	End Control

	Control List Inherits Listbox
		ControlInstance List Inherits Listbox
	End Control
	Property n As MyView
End Class

//===
Class MyView Inherits CustomNSViewMBS
EventHandler Function beginGestureWithEvent(e as NSEventMBS) As boolean
window1.List.insertRow 0, CurrentMethodName
End EventHandler
EventHandler Function endGestureWithEvent(e as NSEventMBS) As boolean
window1.List.insertRow 0, CurrentMethodName
End EventHandler
EventHandler Function magnifyWithEvent(e as NSEventMBS) As boolean

// IF* this worked, I haven’t yet worked out what use the NSEventMBS would be
// Do we need to make a note that a gesture started first?
// What does ‘zoom in’ or ‘zoom out’ look like?
// How do you make it work with a Canvas which is not a CustomNSViewMBS?

		window1.List.insertRow 0, CurrentMethodName
	End EventHandler
	EventHandler Function rotateWithEvent(e as NSEventMBS) As boolean
		window1.List.insertRow 0, CurrentMethodName
	End EventHandler
	EventHandler Function swipeWithEvent(e as NSEventMBS) As boolean
		window1.List.insertRow 0, CurrentMethodName
	End EventHandler
End Class

End Project[/code]

Did you install MBS Plugins?

You need Main, MacControls, MacBase and MacCocoa at least.

Yes.
All present

The project also doesn’t do anything on a MacBook Air. No swipe, no rotate: no gesture at all.