Touch messages problem...
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Touch messages problem...
Hi…
For all of you that have been using 'touch' messages, I wonder if you can help me out with this one. I have two cards in the stack…
On card 1 I have a scroller built over a group… If you drag down then the group will follow and bounce as expected. If however you 'swipe' in the top round rectangle on card 1, wanting to go to the next card.. it will, using the 'touch' messages that are in the script of the top round rectangle, go to card 2.
Up to here is fine… there is a button on card 2 to take you back to card 1. It does not let me go back to card 1… Why ?
One thing that I have noticed is that if I take out the touch messages in the top round rectangle of card 1 and just use ordinary mouseUp, mouseDown commands to go to card 2, then it all works well… The problem it seems is in mixing touch messages in an object of a group (in this case the top round rectangle) that is covered by a scroller…
Anyone come across this ?… I have attached the stack.
be well
Dixie
For all of you that have been using 'touch' messages, I wonder if you can help me out with this one. I have two cards in the stack…
On card 1 I have a scroller built over a group… If you drag down then the group will follow and bounce as expected. If however you 'swipe' in the top round rectangle on card 1, wanting to go to the next card.. it will, using the 'touch' messages that are in the script of the top round rectangle, go to card 2.
Up to here is fine… there is a button on card 2 to take you back to card 1. It does not let me go back to card 1… Why ?
One thing that I have noticed is that if I take out the touch messages in the top round rectangle of card 1 and just use ordinary mouseUp, mouseDown commands to go to card 2, then it all works well… The problem it seems is in mixing touch messages in an object of a group (in this case the top round rectangle) that is covered by a scroller…
Anyone come across this ?… I have attached the stack.
be well
Dixie
- Attachments
-
- TouchMessagesProblem.zip
- (9.93 KiB) Downloaded 292 times
Re: Touch messages problem...
Dixie:
While not an expert by any stretch of the imagination, why not use touch messages in place of mouse messages?
I have revised your stack with a touch message on goSet of card 2 which seems to do what you want...
Hope this helps,
Todd
While not an expert by any stretch of the imagination, why not use touch messages in place of mouse messages?
I have revised your stack with a touch message on goSet of card 2 which seems to do what you want...
Hope this helps,
Todd
Re: Touch messages problem...
Hi Dixie,
the problem is not touch versus mouse.
The problem is that you put the go command into the touchmove: it fires too many times and somehow stalls the app (makes it unresponsive to the mouseDown/Up in the button.
Then you expect a swipe to go to the next card. Actually I would expect a mouseUp. The swipe scrolls, the selection is made by touching.
I propose a change to the script of graphic "round rectangle" of card 1
If you really want a swipe you could change
to
I would also suggest to swap the icons in the button on card 2. 6000 is the dark one for pressed -> on mouseDown, 6001 the light one on mouseUp/release
Are you shure you want to use a global for the sScollID on card 1, I always use a script local for that and never have to worry about where who and what writes to that global.
Kind regards
Bernd
the problem is not touch versus mouse.
The problem is that you put the go command into the touchmove: it fires too many times and somehow stalls the app (makes it unresponsive to the mouseDown/Up in the button.
Then you expect a swipe to go to the next card. Actually I would expect a mouseUp. The swipe scrolls, the selection is made by touching.
I propose a change to the script of graphic "round rectangle" of card 1
Code: Select all
local hdiff
on touchStart theID
put item 1 of mouseLoc() into hdiff
end touchStart
on touchEnd theID
put item 1 of the mouseLoc into x
if abs (x - hdiff) < 10 then -- you want to catch selection, not a swipe
visual effect push left slow
go next
end if
end touchEnd
Code: Select all
if abs (x - hdiff) < 10 then -- you want to catch selection, not a swipe
Code: Select all
if x - hdiff < 40 then -- you would only want to go right
Are you shure you want to use a global for the sScollID on card 1, I always use a script local for that and never have to worry about where who and what writes to that global.
Kind regards
Bernd
Re: Touch messages problem...
Bernd:
Good morning.
If she is not really wanting to detect a swipe, but a touch, is all of that really necessary?
Could you not achieve the same result on the card 1 rounded rectangle with:
If not detecting a swipe, why evaluate a change in x at all?
Is a touchEnd necessary? If so, could it be appended as:
Hope you are well!
:Todd
Good morning.
If she is not really wanting to detect a swipe, but a touch, is all of that really necessary?
Could you not achieve the same result on the card 1 rounded rectangle with:
Code: Select all
on touchStart theID
visual effect push left slow
go next card
end touchStart
Is a touchEnd necessary? If so, could it be appended as:
Code: Select all
on touchStart theID
--nothing here?
end touchStart
on touchEnd theID
visual effect push left slow
go next card
end touchEnd
:Todd
Re: Touch messages problem...
Hi Todd,
You can try to put it on touchstart, you will not be able to start a scroll from that area.
Edit:
I don't know if John wanted to swipe or not. But in my view it should be a touch. (This sentence is just added to set the gender right
)
Edit 2:
You can do it with touchEnd. Then the cancelTouches = true takes care of the scroll/touch problem. I picked up this habit when there was not yet a native scroller. I have to reconsider it.
Kind regards
Bernd
It is because it is in a scrolling area, it helps to differentiate between the begin of a scroll and a selection-touch. When touching on a real device you often have also a move, since the fingers have a certain area. In my experience it is under 10 pixel if you want to make a selection with a touch and more if you start a scroll.If she is not really wanting to detect a swipe, but a touch, is all of that really necessary?
You can try to put it on touchstart, you will not be able to start a scroll from that area.
Edit:
I don't know if John wanted to swipe or not. But in my view it should be a touch. (This sentence is just added to set the gender right

Edit 2:
You can do it with touchEnd. Then the cancelTouches = true takes care of the scroll/touch problem. I picked up this habit when there was not yet a native scroller. I have to reconsider it.
Kind regards
Bernd
Re: Touch messages problem...
Ahhh... I get it... and a touch does make more sense to me from a UI standpoint in that area, too.
LOL! I got Dixie's gender wrong? Apologies...
Thanks, on both counts.
:Todd
New stack attached, for reference...
LOL! I got Dixie's gender wrong? Apologies...
Thanks, on both counts.
:Todd
New stack attached, for reference...
- Attachments
-
- Dixie's Stack_v2.livecode.zip
- revised with touchStart/touchEnd
- (9.89 KiB) Downloaded 307 times
Re: Touch messages problem...
Hi Bernd..
I had started off just trying to emulate what happens in "Settings' in the simulator. I had noticed that if you drag down then the rectangles bounce. I then set up a rectangle to take me to another card… I could move to the other, or second card, but did not seem to be able to come back…
I then re-read the release notes with a little more care and discovered the 'iphoneClearTouches' command to clear the touch messages that may have accumulated…
In the top rectangle I have used the 'touch' messages and in the bottom rectangle a 'mouse' message. Calling the 'iphoneClearTouches' command when closing card 1, everything seems to work fine. There seems to be no need to use the 'touch' messages (in this case) as the 'mouse' message performs just as well… in that, if you swipe as you click, in the bottom rectangle graphic is still catching the mouseDown message.
I take your point about moving the script to go to card 2 from the 'touchMove' message to the 'touchEnd' message but had thought perhaps it was better there when having read in the release notes… 'A touchRelease message is sent instead of a touchEnd message if the touch is cancelled due to an incoming event such as a phone-call.' and wondered if it just might confuse everything… ?
You are correct, Bernd… It is a bad habit of mine to declare globals.
The issue of the button press on the second card… it uses the darker image when you click the button, I have it the right way round ? ... You are forgiven, Todd...
be well
Dixie
I had started off just trying to emulate what happens in "Settings' in the simulator. I had noticed that if you drag down then the rectangles bounce. I then set up a rectangle to take me to another card… I could move to the other, or second card, but did not seem to be able to come back…
I then re-read the release notes with a little more care and discovered the 'iphoneClearTouches' command to clear the touch messages that may have accumulated…
In the top rectangle I have used the 'touch' messages and in the bottom rectangle a 'mouse' message. Calling the 'iphoneClearTouches' command when closing card 1, everything seems to work fine. There seems to be no need to use the 'touch' messages (in this case) as the 'mouse' message performs just as well… in that, if you swipe as you click, in the bottom rectangle graphic is still catching the mouseDown message.
I take your point about moving the script to go to card 2 from the 'touchMove' message to the 'touchEnd' message but had thought perhaps it was better there when having read in the release notes… 'A touchRelease message is sent instead of a touchEnd message if the touch is cancelled due to an incoming event such as a phone-call.' and wondered if it just might confuse everything… ?
You are correct, Bernd… It is a bad habit of mine to declare globals.
The issue of the button press on the second card… it uses the darker image when you click the button, I have it the right way round ? ... You are forgiven, Todd...

be well
Dixie
- Attachments
-
- TestScrollBounce.livecode.zip
- (10.11 KiB) Downloaded 292 times
Re: Touch messages problem...
Hi John,
it works for me in the Simulator the way you have set it up. The icons are also ok.
If you test gestures in the simulator there is always the problem the the mouse behaves differently from the actual device. Touches and gestures are best tested on a device.
E.g. if you touch you almost always trigger a mousemove on the device. Suppose someone is a bit clumsy with his fingers. Me for example.
I want to scroll but my jerky touches make a mouseMove to the right while touching this would trigger going to the card since the touchmove says so. I would be surprised since I actually wanted to scroll. I would have to go back and would not like the app since it did not what I wanted it to do.
I would trigger the going to the next card in a mouseUP or touchend handler (with or without a distance). That is the only message you can rely on in this context. It is a bit confusing since the canCancelTouches comes into play when touching in a scroll area.
In my experience canCancelTouches triggers as soon as the mousemove = > 10. Then your handling of the events is overruled by the canCancelTouches if it is set to true.
BTW I use touch and mouse interchangeably, for single touch events. The only difference I see is the the touch ID which comes into play if you have multitouch events.
Kind regards
Bernd
it works for me in the Simulator the way you have set it up. The icons are also ok.
If you test gestures in the simulator there is always the problem the the mouse behaves differently from the actual device. Touches and gestures are best tested on a device.
E.g. if you touch you almost always trigger a mousemove on the device. Suppose someone is a bit clumsy with his fingers. Me for example.
I want to scroll but my jerky touches make a mouseMove to the right while touching this would trigger going to the card since the touchmove says so. I would be surprised since I actually wanted to scroll. I would have to go back and would not like the app since it did not what I wanted it to do.
I would trigger the going to the next card in a mouseUP or touchend handler (with or without a distance). That is the only message you can rely on in this context. It is a bit confusing since the canCancelTouches comes into play when touching in a scroll area.
In my experience canCancelTouches triggers as soon as the mousemove = > 10. Then your handling of the events is overruled by the canCancelTouches if it is set to true.
BTW I use touch and mouse interchangeably, for single touch events. The only difference I see is the the touch ID which comes into play if you have multitouch events.
Kind regards
Bernd