# Widgets don't react to trackpad gestures on Mac OS

**URL:** <https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950>\
**Category:** Widgets\
**Created:** [August 2, 2017, 9:01pm UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950 "2017-08-02T21:01:08Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![gsimeonov](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/g/439d5e/32.png) [@gsimeonov](https://forums.solar2d.com/u/gsimeonov)\
**Post date:** [August 2, 2017, 9:01pm UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950/1 "2017-08-02T21:01:08Z")

</div>

So the widgets that offer some sort of scrolling - **PickerWheel** , **ScrollView** , and **TableView** don’t respond to the standard **2-finger gesture** on a Mac trackpad that is used for scrolling (any kind of scrollable content).

I understand this might be considered a special case, but I almost exclusively use the trackpad instead of a mouse and very rarely stumble upon content I can’t scroll with 2 fingers. And I suspect I am not the only user who expects such behaviour.

I also realize the widgets are probably intended to be used exclusively on mobile platforms, but I’ve got this idea about a UI-heavy game that works on Desktop (Win 10, Mac)…

… And I’m accepting advices on how to deal with the above mentioned issue 🙂

---

<div class="post-metadata">

**Author:** ![roaminggamer](https://forums.solar2d.com/user_avatar/forums.solar2d.com/roaminggamer/32/134_2.png) [@roaminggamer](https://forums.solar2d.com/u/roaminggamer)\
**Post date:** [August 2, 2017, 9:03pm UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950/2 "2017-08-02T21:03:35Z")

</div>

This might help.

[https://marketplace.coronalabs.com/plugin/mac-trackpad](https://marketplace.coronalabs.com/plugin/mac-trackpad)

I can’t be sure, but it is easy enough to try and at this point it is free.

---

<div class="post-metadata">

**Author:** ![roaminggamer](https://forums.solar2d.com/user_avatar/forums.solar2d.com/roaminggamer/32/134_2.png) [@roaminggamer](https://forums.solar2d.com/u/roaminggamer)\
**Post date:** [August 2, 2017, 9:31pm UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950/3 "2017-08-02T21:31:23Z")

</div>

If that doesn’t lead you in a useful direction, you’ll have to download the widget code and modify it to support the touch model you describe. &nbsp;

Thankfully you can do that.

Remember the widgets were designed for mobile use first (in fact before Corona even supported desktop builds) so it is not a surprise that they don’t support your usage out of the box.

Nonetheless, I think there are ways you can resolve this.

-Ed

PS - If someone can’t lend you their time to resolve this, this might be doable as a [hit](https://forums.coronalabs.com/topic/69420-hire-a-hitman-problem-solver-is-back/). &nbsp;At what level I’m not yet sure.

---

<div class="post-metadata">

**Author:** ![gsimeonov](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/g/439d5e/32.png) [@gsimeonov](https://forums.solar2d.com/u/gsimeonov)\
**Post date:** [August 2, 2017, 11:40pm UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950/4 "2017-08-02T23:40:36Z")

</div>

Thanks!

The plugin doesn’t seem to support this type of gestures but it’s nice to know it’s achievable.

I just saw mouse scrolling doesn’t work either. And these particular widgets don’t look very intuitive on desktop anyway, so it might be a good idea to just avoid them altogether.

---

<div class="post-metadata">

**Author:** ![roaminggamer](https://forums.solar2d.com/user_avatar/forums.solar2d.com/roaminggamer/32/134_2.png) [@roaminggamer](https://forums.solar2d.com/u/roaminggamer)\
**Post date:** [August 3, 2017, 12:41am UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950/5 "2017-08-03T00:41:54Z")

</div>

You can fairly easily make the scroller ‘mouse/trackpad’ scroll-able.

I’ve done so just recently.

The basic trick is:

1. Use a key listener for the mouse scroll event (catches mice and trackpad scrolls).

2. Dispatch a custom event ‘scrollWidget’ or anything you want to name it.

3. Have the scroller catch the event.

4. In the scroller event listener for that event, use the scroller’s methods to scoll the widget by a fixed amount.

Done.

---

<div class="post-metadata">

**Author:** ![Scott\_Harrison](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/s/65b543/32.png) [@Scott\_Harrison](https://forums.solar2d.com/u/Scott_Harrison)\
**Post date:** [August 3, 2017, 2:23am UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950/6 "2017-08-03T02:23:48Z")

</div>

That plugin was designed for what is not offers in terms of gestures. Rotate, pinch, and force (on newer trackpads).

---

<div class="post-metadata">

**Author:** ![gsimeonov](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/g/439d5e/32.png) [@gsimeonov](https://forums.solar2d.com/u/gsimeonov)\
**Post date:** [August 3, 2017, 7:54am UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950/7 "2017-08-03T07:54:41Z")

</div>

> [@roaminggamer](#):
>
> You can fairly easily make the scroller ‘mouse/trackpad’ scroll-able.
> 
> I’ve done so just recently.
> 
> The basic trick is:
> 
> 1. Use a key listener for the mouse scroll event (catches mice and trackpad scrolls).
> 
> 2. Dispatch a custom event ‘scrollWidget’ or anything you want to name it.
> 
> 3. Have the scroller catch the event.
> 
> 4. In the scroller event listener for that event, use the scroller’s methods to scoll the widget by a fixed amount.
> 
> Done.

Thanks for the tips!

But I don’t see a ‘mouse scroll’ event in the API list, just a general ‘mouse’ event and three (primary/secondary/middle)ButtonDown’s. No idea how to determine if it’s a scroll or just moving the cursor around.

If I have to do something that’s not already in the Corona API, I’d rather give up the idea of dealing with it on my own.

---

<div class="post-metadata">

**Author:** ![nick\_sherman](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/n/958977/32.png) [@nick\_sherman](https://forums.solar2d.com/u/nick_sherman)\
**Post date:** [August 3, 2017, 8:16am UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950/8 "2017-08-03T08:16:01Z")

</div>

This is the code I’m using for mouse wheel scrolling. Works from an undocumented property called .scrollY.

It can be adapted slightly to work on tableViews as well.

[lua]

local middleMouseButtonScrollSpeed = **400** ;

&nbsp;local mouseScroll = function (event)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; local sv = event.target

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; local scrollInfo = {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dist = event.scrollY, – not officially part of the Corona SDK

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; time = event.time-sv.lastTime

&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp; sv.lastTime = event.time;

&nbsp;&nbsp;&nbsp; – Add it to the scroll info table

&nbsp;&nbsp;&nbsp; sv.scrollInfoTable[#sv.scrollInfoTable+ **1**] = scrollInfo;

&nbsp;&nbsp;&nbsp; – Take an average from the last **10** (or up to that if table smaller)

&nbsp;&nbsp;&nbsp; local sampleSize = #sv.scrollInfoTable;

&nbsp; &nbsp;&nbsp;if sampleSize \> **10** then

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sampleSize = **10** ;

&nbsp;&nbsp;&nbsp; end

&nbsp;&nbsp;&nbsp; local averageDist = **0** ; local averageTime = **0** ;

&nbsp;&nbsp;&nbsp; for i=#sv.scrollInfoTable, (#sv.scrollInfoTable+ **1** -sampleSize), - **1** do

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; averageDist = averageDist + sv.scrollInfoTable[i] **.d** ist;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; averageTime = averageTime + sv.scrollInfoTable[i] **.t** ime;

&nbsp;&nbsp;&nbsp; end

&nbsp;&nbsp;&nbsp; averageDist = averageDist / sampleSize;

&nbsp;&nbsp;&nbsp; averageTime = averageTime / sampleSize;

&nbsp;&nbsp;&nbsp; local speed = math.round((averageDist/averageTime) \* middleMouseButtonScrollSpeed);

&nbsp;&nbsp;&nbsp; local py, px = sv:getContentPosition();

&nbsp;&nbsp;&nbsp; local currentPosition = py;

&nbsp;&nbsp;&nbsp; local newPosition = currentPosition - speed;

&nbsp;&nbsp;&nbsp; – Don **'t allow the scroll content to go off the bottom**

**&nbsp;&nbsp;&nbsp; – Would be nice to add “bounce” effect at some point**

**&nbsp;&nbsp;&nbsp; if newPosition \> 0 then**

**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newPosition = 0;**

**&nbsp;&nbsp;&nbsp; end**

**&nbsp;&nbsp;&nbsp; – Or off the top**

**&nbsp;&nbsp; local contentHeight = sv.\_collectorGroup.height;**

**&nbsp;&nbsp;&nbsp; if contentHeight \> sv.ht then**

**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if newPosition \< (sv.\_collectorGroup.height-contentHeight) then**

**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newPosition = sv.\_collectorGroup.height-contentHeight;**

**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end**

**&nbsp;&nbsp;&nbsp; else**

**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newPosition = 0;**

**&nbsp;&nbsp;&nbsp; end**

**&nbsp;&nbsp;&nbsp; – Do the actual scrolling (if scroll speed isn’t** zero)

&nbsp;&nbsp; if speed ~= **0** then

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sv:scrollToPosition {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x = **0** ,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; y = newPosition,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; time = **0** ,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; onComplete = nil

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp; end

&nbsp;&nbsp;&nbsp; – Remove any extra records from the table so we don’t use up any unnecessary memory

&nbsp;&nbsp;&nbsp; if #sv.scrollInfoTable \> sampleSize then

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; table.remove(sv.scrollInfoTable, 1);

&nbsp;&nbsp;&nbsp; end

&nbsp; end

&nbsp; – assuming your scrollview is named ‘sv’

&nbsp; sv:addEventListener( “mouse”, mouseScroll );

&nbsp; sv.scrollInfoTable = {}

&nbsp; sv.lastTime = system.getTimer()

[/lua]

---

<div class="post-metadata">

**Author:** ![gsimeonov](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/g/439d5e/32.png) [@gsimeonov](https://forums.solar2d.com/u/gsimeonov)\
**Post date:** [August 3, 2017, 10:28am UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950/9 "2017-08-03T10:28:08Z")

</div>

> [@nick\\\_sherman](#):
>
> This is the code I’m using for mouse wheel scrolling. Works from an undocumented property called .scrollY.
> 
> It can be adapted slightly to work on tableViews as well.
> 
> [lua]…[/lua]

Thanks a lot! It doesn’t seem applicable to PickerWheel but I should be able to use TableView instead.

I assume **\_collectorGroup** is another undocumented property 🙂

---

<div class="post-metadata">

**Author:** ![rob](https://forums.solar2d.com/user_avatar/forums.solar2d.com/rob/32/4_2.png) [@rob](https://forums.solar2d.com/u/rob)\
**Post date:** [August 3, 2017, 12:40pm UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950/10 "2017-08-03T12:40:41Z")

</div>

Just as an FYI…

Any widget property that starts with an \_ is meant to be a private member and we may change it in the future with little or no warning. So yes, it’s undocumented on purpose.

Are we likely to change it? Probably not, but it’s still a “use at your own risk” property.

Rob

---

<div class="post-metadata">

**Author:** ![roaminggamer](https://forums.solar2d.com/user_avatar/forums.solar2d.com/roaminggamer/32/134_2.png) [@roaminggamer](https://forums.solar2d.com/u/roaminggamer)\
**Post date:** [August 3, 2017, 4:07pm UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950/11 "2017-08-03T16:07:34Z")

</div>

Look at the mouse event:

[https://docs.coronalabs.com/api/event/mouse/index.html](https://docs.coronalabs.com/api/event/mouse/index.html)

You’re not looking for something literally called mouse scroll.

This code is the mouse listener from a project of mine.

\_ **WARNING!** \_ &nbsp;Uses SSK for post, listen, helper functions etc. &nbsp;I am not going to convert it to basic Corona, but it should be clear enough what it does. &nbsp;[https://roaminggamer.github.io/RGDocs/pages/SSK2/globals/#runtime-improvements](https://roaminggamer.github.io/RGDocs/pages/SSK2/globals/#runtime-improvements)

```
local function onMouse( event ) -- Dispatch scroll events if( event.scrollY \< 0 ) then post( "onMouseScroll", { direction = (common.invertMouse) and "down" or "up", x = event.x, y = event.y } ) elseif( event.scrollY \> 0 ) then post( "onMouseScroll", { direction = (common.invertMouse) and "up" or "down", x = event.x, y = event.y } ) end end; listen( "mouse", onMouse )
```

---

<div class="post-metadata">

**Author:** ![gsimeonov](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/g/439d5e/32.png) [@gsimeonov](https://forums.solar2d.com/u/gsimeonov)\
**Post date:** [August 4, 2017, 6:10pm UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950/12 "2017-08-04T18:10:27Z")

</div>

> [@roaminggamer](#):
>
> Look at the mouse event:
> 
> …

Thank you for the example. Your SSK collection looks quite useful and I got carried away browsing it.

I also saw&nbsp;[https://docs.coronalabs.com/api/event/axis/index.html](https://docs.coronalabs.com/api/event/axis/index.html), but I couldn’t even make the example code print anything at all. Tried both trackpad and a mouse.

I still hope the Corona team would make the widgets scrollable with mouse/trackpad - even if only in the simulator, as this would make testing much easier.

---

<div class="post-metadata">

**Author:** ![roaminggamer](https://forums.solar2d.com/user_avatar/forums.solar2d.com/roaminggamer/32/134_2.png) [@roaminggamer](https://forums.solar2d.com/u/roaminggamer)\
**Post date:** [August 4, 2017, 6:15pm UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950/13 "2017-08-04T18:15:57Z")

</div>

I wouldn’t hold my breath. &nbsp;

1. Unless you filed an official feature request and it gets voted on the idea stops here. &nbsp;The staff (rightly so) rarely takes forums posts as suggestions for changes.

2. This is a feature that would require a significant amount of work to implement in the many scroll-able widgets and it would risk breaking existing functionality.

3. Implementing this yourself for the specific widgets you want and in the way you specifically want them to behave can be coded via Runtime listeners and calls to official widget functions/methods with about 40 lines of code or so.

---

<div class="post-metadata">

**Author:** ![rob](https://forums.solar2d.com/user_avatar/forums.solar2d.com/rob/32/4_2.png) [@rob](https://forums.solar2d.com/u/rob)\
**Post date:** [August 4, 2017, 6:44pm UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950/14 "2017-08-04T18:44:43Z")

</div>

@roaminggamer is right. We do not use the forums for tracking bugs or feature requests. &nbsp;We have a tool for feature requests and there is one for this:

[http://feedback.coronalabs.com/forums/188732-corona-feature-requests-feedback/suggestions/11517033-mouse-scroll-wheel-with-scrollview-widget](http://feedback.coronalabs.com/forums/188732-corona-feature-requests-feedback/suggestions/11517033-mouse-scroll-wheel-with-scrollview-widget)

This only has 9 votes (at the time I’m posting this). I don’t know if that means 9 people want it a little bit or 3 people want it a lot. Still it’s not much in the way of saying as a community this is important. You will note it’s marked started because we thought it was a good idea too and shouldn’t be too difficult to implement. But we hit some bugs that we are not comfortable releasing and we put it on the back burner and have moved on to other priorities.

We will probably need to see more community interest in this to get it back on the road map. Please vote it up. That’s what we need from you.

Rob

---

<div class="post-metadata">

**Author:** ![gsimeonov](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/g/439d5e/32.png) [@gsimeonov](https://forums.solar2d.com/u/gsimeonov)\
**Post date:** [August 4, 2017, 6:45pm UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950/15 "2017-08-04T18:45:05Z")

</div>

> I wouldn’t hold my breath. &nbsp;
> 
> &nbsp;
> 
> …

&nbsp;

Yes, I saw there is such request with a few votes. The existing community seems to be almost exclusively focused on the mobile platforms (iOS and Android). And the new users like me probably don’t know (or are not that involved yet in Corona) about the feature requests.

Anyway, I got some good tips here and if I need more help with this, I’ll probably use your Hitman service.

> [@rob](#):
>
> …
> 
> We will probably need to see more community interest in this to get it back on the road map. Please vote it up. That’s what we need from you.
> 
> Rob

Just voted, thanks!

---

<div class="post-metadata">

**Author:** ![roaminggamer](https://forums.solar2d.com/user_avatar/forums.solar2d.com/roaminggamer/32/134_2.png) [@roaminggamer](https://forums.solar2d.com/u/roaminggamer)\
**Post date:** [August 2, 2017, 9:03pm UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950/16 "2017-08-02T21:03:35Z")

</div>

This might help.

[https://marketplace.coronalabs.com/plugin/mac-trackpad](https://marketplace.coronalabs.com/plugin/mac-trackpad)

I can’t be sure, but it is easy enough to try and at this point it is free.

---

<div class="post-metadata">

**Author:** ![roaminggamer](https://forums.solar2d.com/user_avatar/forums.solar2d.com/roaminggamer/32/134_2.png) [@roaminggamer](https://forums.solar2d.com/u/roaminggamer)\
**Post date:** [August 2, 2017, 9:31pm UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950/17 "2017-08-02T21:31:23Z")

</div>

If that doesn’t lead you in a useful direction, you’ll have to download the widget code and modify it to support the touch model you describe. &nbsp;

Thankfully you can do that.

Remember the widgets were designed for mobile use first (in fact before Corona even supported desktop builds) so it is not a surprise that they don’t support your usage out of the box.

Nonetheless, I think there are ways you can resolve this.

-Ed

PS - If someone can’t lend you their time to resolve this, this might be doable as a [hit](https://forums.coronalabs.com/topic/69420-hire-a-hitman-problem-solver-is-back/). &nbsp;At what level I’m not yet sure.

---

<div class="post-metadata">

**Author:** ![gsimeonov](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/g/439d5e/32.png) [@gsimeonov](https://forums.solar2d.com/u/gsimeonov)\
**Post date:** [August 2, 2017, 11:40pm UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950/18 "2017-08-02T23:40:36Z")

</div>

Thanks!

The plugin doesn’t seem to support this type of gestures but it’s nice to know it’s achievable.

I just saw mouse scrolling doesn’t work either. And these particular widgets don’t look very intuitive on desktop anyway, so it might be a good idea to just avoid them altogether.

---

<div class="post-metadata">

**Author:** ![roaminggamer](https://forums.solar2d.com/user_avatar/forums.solar2d.com/roaminggamer/32/134_2.png) [@roaminggamer](https://forums.solar2d.com/u/roaminggamer)\
**Post date:** [August 3, 2017, 12:41am UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950/19 "2017-08-03T00:41:54Z")

</div>

You can fairly easily make the scroller ‘mouse/trackpad’ scroll-able.

I’ve done so just recently.

The basic trick is:

1. Use a key listener for the mouse scroll event (catches mice and trackpad scrolls).

2. Dispatch a custom event ‘scrollWidget’ or anything you want to name it.

3. Have the scroller catch the event.

4. In the scroller event listener for that event, use the scroller’s methods to scoll the widget by a fixed amount.

Done.

---

<div class="post-metadata">

**Author:** ![Scott\_Harrison](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/s/65b543/32.png) [@Scott\_Harrison](https://forums.solar2d.com/u/Scott_Harrison)\
**Post date:** [August 3, 2017, 2:23am UTC](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950/20 "2017-08-03T02:23:48Z")

</div>

That plugin was designed for what is not offers in terms of gestures. Rotate, pinch, and force (on newer trackpads).

[Next page](https://forums.solar2d.com/t/widgets-dont-react-to-trackpad-gestures-on-mac-os/344950.md?page=2)
