OpenLayers: Timing of singleClick versus pointerMove events on touch devices - hover

www.skitourenguru.com uses singleClick (click) and pointerMove (hover) events. On touch devices the corresponding gestures are similarly:
singleClick: Tap short with your finger
pointerMove: Tap with your finger, but stay a little bit longer on the touch screen
Is it possible to change the timing with OpenLayers? Right now a pointerMove is triggered, if lets say the finger stays longer then 0.3 sec (estimated!) on the touch screen. That makes it difficult to trigger a singleClick event. Not all users have that fast fingers!
Ideal would be to raise the discrimination time to lets say 1.0 sec:
Stay less then 1.0 sec on the touch screen: Its a singleClick event (Purpose: click on something).
Stay more then 1.0 sec on the touch screen: Its a pointerMove event (Purpose: hover)
I thought to remove "hover" from touch devices. However its not a good idea to try to identify touch screen devices these days. There are devices with mouse AND touch.

Related

Which event is fired when releasing a HTML input range (slider) on touch device?

In my Angular 2 app I use a plain vanilla HTML5 input type "range" to provide the user a simple slider component.
<input type="range" [min]="x" [max]="y" (mouseup)="onReleased()" />
I need to know when the user released the slider. Releasing means that using a mouse the dragging is finished and the mouse button has been released. For that purpose I hook into the OnMouseUp event. However, this does not apply in case I use a touch device.
On my tablet I can drag the slider aroun, but when releasing it with my finger the event is no fired.
I know, this is not a mouse, but what event is equivalent to on mouse up and works on touch devices?
The answer to your question would appear to be the touchend event.
I assume there is a way to make the slider a touch surface within the wider Touch Events Web API

Flash Expandable Banner - Detect Mouse Leave

I have created an expandable banner ad in Flash. Everything is great except one thing. How can I detect when the user is no longer hovering over the flash ad? I have tried to ad a "hit area" which can be used to detect MOUSE_OUT. The issue is, there is a video playing, as well as social media buttons which need to be clickable. If I place a hit area over these, they are no longer clickable. If I place the hit area behind the buttons, the MOUSE_OUT event triggers when you hover over the button.
What is the best practice for a scenario such as this? I have also tried detecting MOUSE_LEAVE on the stage object, but this doesn't seem to function correctly once deployed on an HTML page. Thanks for the assistance.
You can try adding an ENTER_FRAME event that constantly checks stage.mouseX and stage.mouseY. These values should report correctly while the mouse is on the Flash content, and will report the last known mouse coordinates when the mouse is no longer on the stage. However, the last known mouse coordinates may not always be the actual width or height of the stage, so you probably want to add some tolerance in there.
For instance, if your (expanded) Flash content width is 500px, in the ENTER_FRAME event you can check if stage.mouseX is less than 10px (mouse moving off to the left) or more than 490px (mouse is moving off to the right) and minimize the Flash content. Repeat for the height, and adjust tolerance values as needed.
This should give you the effect you want. The only downside that I can see is the overhead of the ENTER_FRAME event just to check whether the mouse has left the content, but I don't see any way around that.

action script 3 - is it possible to simulate pressure on mouse down

I was wondering if is there is possible to detect the pressure (how hard the mouse button is pressed and kept hold) on mouse? If not, can we simulate it by some technique/method?
There is no way to detect the amount of pressure applied to the mouse button or pad for that matter.
IMO the best way to simulate this effect would be to work with some kind of timer - where you log the time from mouseDown to mouseUp and calculate what this means in terms of pressure. To help the user i would make some kind of graphical indication as the pressure is mounting (ie time is spent holding the mouse button down)
No way, you cannot detect how hard the button was pressed.
Keep in mind that the mouse is a digital input, that means that when you click it you're pressing a switch that only has two states (ON/OFF). No pressure amount info sent to the computer. It's not a limit of Flash, it's a limit of the input device. Try open a mouse and you'll see the switches below the mouse buttons.
But as #Dennis Flood said, you can use a timer to calculate how long it was pressed (on mouse down start a timer, then on mouse up stop the timer and calculate the time).
I dunno if you have some experience with Arduino, but I would use it if you're working on an off-line sytem (like an installation). You could use some analog pressure sensors instead of your mouse and send the values to flash.

touchscreen: distinguish start of scroll from tap

I'm writing something for a touchscreen phone. I'd like the program to run a specified function when the user taps on the screen. I'd like to scroll the screen when the user drags a finger up or down the screen.
The OS has three relevant callback functions (1) detect when screen is touched, (2) detect when finger is dragged on screen and (3) detect when the finger leaves the screen. In each case, the callback function gets the screen coordinates where the relevant event happened.
The problem is that a drag obviously starts with a finger touching the screen and ends when the finger leaves the screen. Tapping is usually detected as a touch, very short drag and end touch. If I just call my specified function on a tap, I'll trigger on screen drag events rather than genuine taps.
The best I can think of is to mark the time or location when the user first touches. If we are in the drag callback function a short time or distance later, treat it as a scroll. Otherwise, if there's been a leave-the-screen callback, treat it as a tap. Issues include the cost of noting the time, deciding how much time or distance to use as a trigger and if there is a better general approach.
My app is in python for a symbian device. As that's not a very popular platform, any suggestions for the best way to implement would be appreciated.
The best approach I can think of is:
Touch callback: set action_location = drag_location = current_location (current_location reported by os)
Un-touch callback: if action_location within distance_threshold (e.g., 20 or 25 pixels) of current_location, execute action
Drag callback: if drag_location more than distance_threshold from current_location, scroll and set drag_location = current_location

Adobe AIR: touch screen doesn't trigger mouse down event correctly

i have designed a gaming kiosk app in as3
i am using it on a Sony vaio l pc (like hp's touchsmarts) in windows 7
the app doesn't need any multi-touch gestures (only single touch clicks and drags) so i am using mouse events
everything is fine (including mouse click and move events) except that a single touch to the screen (with no move) doesn't fire a mouse down. it is fired only after a small move of the finger
outside the app, on my desktop, i see that the small windows 7 cursor jumps immediately to where a finger is placed, meaning this issue isn't a hardware or a windows problem but rather how internally the flash app receives "translated" touch-to-mouse events from the os.
for example, in a windows Solitaire game, a simple touch to the screen immediately highlights the touched card.
in my app, a button will change to the down state only if i touch it and also move my finger slightly (click events - down and up - are triggered fine)
shouldn't the MOUSE_DOWN event trigger exactly like how a TOUCH_BEGIN would in the new touchevent class?
any ideas?
I encountered the same problem.
Setting the Multitouch.inputMode property to MultitouchInputMode.TOUCH_POINT (the default value is MultitouchInputMode.GESTURE) appears to make the MOUSE_DOWN event dispatch when the user touches the screen and not when they touch and move or touch and release.
If the cursor moves when they touch, then I assume the OS is just registering this as a MOUSE_MOVE and not a MOUSE_DOWN. Since it's a touchscreen, you could just consider MOUSE_MOVE a click since the user probably isn't actually dragging their finger around creating a real MOUSE_MOVE event.
Well, if they are actually dragging their finger around for stuff then you could assume a MOUSE_MOVE that suddenly places the cursor on a button (with no prior MOUSE_MOVE i.e. dragging), it's a MOUSE_DOWN.
Just bought a new touchscreen and encountered the problem again.
So the solution is to set Multitouch.inputMode to MultitouchInputMode.TOUCH_POINT by writing anywhere in your code:
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
Notice, that it does not work when testing by Ctrl+Enter in Flash Editor (at least in CC 2015). So, for example, you need to open .SWF separately in Flash Player.
EDIT: But it does work in Debug mode! (Ctrl+Shift+Enter)