Complete
over 5 years ago

The events were being sent to onPreviousPage() and onNextPage() in the BehaviorDelegate.

Touchscreen onSwipeEvent(evt) Inconsistent

Here is the Behavior Delegate I have implemented. 

During a Swipe, 

Right Swipe always ends up being onBack(), and up/down swipes do not seem to be registering the onSwipe action. Am I implementing this wrong? I have tried this on hand with a Vivoactive 3 and Venu.

class UpDownWrapper extends Ui.BehaviorDelegate {
	
    function initialize() {
		BehaviorDelegate.initialize();
    }

	function onSwipe(evt) {
        var event = evt.getDirection();
        Sys.println("event: " + event);
        if (event == Ui.SWIPE_LEFT) {
			// Do Left thing
		} else if (event == Ui.SWIPE_RIGHT) {
			// Do Right thing
		} else if (event == Ui.SWIPE_UP) {
			// Do up thing
		} else if (event == Ui.SWIPE_DOWN) {
			// do down thing
		} else {
			return true;
		}
	}

}

Parents
  • right swipe is onBack on some of the touch devices.  With the va3 for example, there is only one button, so there's a need for a way to do onBack()

    Instead of what you're doing, you can just do something like:

    function onNextPage() {
        	view.currentIdx++;
        	if(view.currentIdx>=view.scanResults.size()) {view.currentIdx=0;}
        	Ui.requestUpdate();
        	return true;
        }
        
        function onPreviousPage() {
        	view.currentIdx--;
        	if(view.currentIdx<0) {view.currentIdx=view.scanResults.size()-1;}
        	Ui.requestUpdate();
        	return true;    
        }

    And it works for both touch and non touch devices.  No need for onSwipe().

Comment
  • right swipe is onBack on some of the touch devices.  With the va3 for example, there is only one button, so there's a need for a way to do onBack()

    Instead of what you're doing, you can just do something like:

    function onNextPage() {
        	view.currentIdx++;
        	if(view.currentIdx>=view.scanResults.size()) {view.currentIdx=0;}
        	Ui.requestUpdate();
        	return true;
        }
        
        function onPreviousPage() {
        	view.currentIdx--;
        	if(view.currentIdx<0) {view.currentIdx=view.scanResults.size()-1;}
        	Ui.requestUpdate();
        	return true;    
        }

    And it works for both touch and non touch devices.  No need for onSwipe().

Children