# Multitouch vs ScrollView with Button

**URL:** <https://forums.solar2d.com/t/multitouch-vs-scrollview-with-button/328814>\
**Category:** Widgets\
**Created:** [September 24, 2014, 10:14am UTC](https://forums.solar2d.com/t/multitouch-vs-scrollview-with-button/328814 "2014-09-24T10:14:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![2reckiy](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/2/838e76/32.png) [@2reckiy](https://forums.solar2d.com/u/2reckiy)\
**Post date:** [September 24, 2014, 10:14am UTC](https://forums.solar2d.com/t/multitouch-vs-scrollview-with-button/328814/1 "2014-09-24T10:14:59Z")

</div>

If turn on multitouch

```
system.activate("multitouch"); 

```

in this code:

```
local widget = require( "widget" ) local scrollView = widget.newScrollView { top = 100, left = 10, width = 300, height = 400, scrollWidth = 600, scrollHeight = 800, horizontalScrollDisabled = true } -- The touch listener function for the button (created below) local function handleButtonEvent( event ) local phase = event.phase if ( phase == "moved" ) then local dy = math.abs( ( event.y - event.yStart ) ) -- If the touch on the button has moved more than 10 pixels, -- pass focus back to the scroll view so it can continue scrolling if ( dy \> 10 ) then scrollView:takeFocus( event ) end end return true end local button1 = widget.newButton { left = 100, top = 200, id = "button1", label = "Default", onEvent = handleButtonEvent } scrollView:insert( button1 )

```

than&nbsp; **handleButtonEvent** won’t work! It’s impossible to tap button.

Be careful, guys. 🙂

---

<div class="post-metadata">

**Author:** ![bjsorrentino](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@bjsorrentino](https://forums.solar2d.com/u/bjsorrentino)\
**Post date:** [September 24, 2014, 8:33pm UTC](https://forums.solar2d.com/t/multitouch-vs-scrollview-with-button/328814/2 "2014-09-24T20:33:27Z")

</div>

Hi @2reckiy,

Are you getting any response at all from the “handleButtonEvent” function? Meaning, if you put a print() statement in there, is it responding at all?

Thanks,

Brent

---

<div class="post-metadata">

**Author:** ![2reckiy](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/2/838e76/32.png) [@2reckiy](https://forums.solar2d.com/u/2reckiy)\
**Post date:** [September 25, 2014, 7:23am UTC](https://forums.solar2d.com/t/multitouch-vs-scrollview-with-button/328814/3 "2014-09-25T07:23:22Z")

</div>

> [@bjsorrentino](#):
>
> Hi @2reckiy,
> 
> Are you getting any response at all from the “handleButtonEvent” function? Meaning, if you put a print() statement in there, is it responding at all?
> 
> Thanks,
> 
> Brent

At first it’s works. But after scroll&nbsp;“handleButtonEvent”&nbsp;does not work anymore.

So i have switch on\off&nbsp;multitouch in&nbsp;certain cases.

I think it helps you.

---

<div class="post-metadata">

**Author:** ![bjsorrentino](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@bjsorrentino](https://forums.solar2d.com/u/bjsorrentino)\
**Post date:** [September 25, 2014, 8:15pm UTC](https://forums.solar2d.com/t/multitouch-vs-scrollview-with-button/328814/4 "2014-09-25T20:15:52Z")

</div>

Hi @2reckiy,

Speaking from a basic design perspective, what behavior is ideal for you? Should the scrollView scroll with one finger touch-drag? If so, what should happen when the user places the second touch down and drags? Should that touch “take control” of the scrollView, or should it be ignored in favor of the original (first) touch? If the user touches the scrollView, should the button be triggered by the second touch, or could the first touch trigger it?

Basically, these type of questions are common when working with multi-touch, which can be quite tricky by basic principle (simply the design considerations, before you do the coding).

It seems like you’re turning off multi-touch at some points, which I believe is the correct approach. It’s useful (and necessary) for some UI/game design, but it’s not appropriate for all scenes/screens in an app.

Take care,

Brent

---

<div class="post-metadata">

**Author:** ![bjsorrentino](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@bjsorrentino](https://forums.solar2d.com/u/bjsorrentino)\
**Post date:** [September 24, 2014, 8:33pm UTC](https://forums.solar2d.com/t/multitouch-vs-scrollview-with-button/328814/5 "2014-09-24T20:33:27Z")

</div>

Hi @2reckiy,

Are you getting any response at all from the “handleButtonEvent” function? Meaning, if you put a print() statement in there, is it responding at all?

Thanks,

Brent

---

<div class="post-metadata">

**Author:** ![2reckiy](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/2/838e76/32.png) [@2reckiy](https://forums.solar2d.com/u/2reckiy)\
**Post date:** [September 25, 2014, 7:23am UTC](https://forums.solar2d.com/t/multitouch-vs-scrollview-with-button/328814/6 "2014-09-25T07:23:22Z")

</div>

> [@bjsorrentino](#):
>
> Hi @2reckiy,
> 
> Are you getting any response at all from the “handleButtonEvent” function? Meaning, if you put a print() statement in there, is it responding at all?
> 
> Thanks,
> 
> Brent

At first it’s works. But after scroll&nbsp;“handleButtonEvent”&nbsp;does not work anymore.

So i have switch on\off&nbsp;multitouch in&nbsp;certain cases.

I think it helps you.

---

<div class="post-metadata">

**Author:** ![bjsorrentino](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@bjsorrentino](https://forums.solar2d.com/u/bjsorrentino)\
**Post date:** [September 25, 2014, 8:15pm UTC](https://forums.solar2d.com/t/multitouch-vs-scrollview-with-button/328814/7 "2014-09-25T20:15:52Z")

</div>

Hi @2reckiy,

Speaking from a basic design perspective, what behavior is ideal for you? Should the scrollView scroll with one finger touch-drag? If so, what should happen when the user places the second touch down and drags? Should that touch “take control” of the scrollView, or should it be ignored in favor of the original (first) touch? If the user touches the scrollView, should the button be triggered by the second touch, or could the first touch trigger it?

Basically, these type of questions are common when working with multi-touch, which can be quite tricky by basic principle (simply the design considerations, before you do the coding).

It seems like you’re turning off multi-touch at some points, which I believe is the correct approach. It’s useful (and necessary) for some UI/game design, but it’s not appropriate for all scenes/screens in an app.

Take care,

Brent
