764 views
in GUI Development by
I hope to make UI, which supports swipe and click.

--------------------------  
|                        |  
|           Area B       |  
|                        |  
|   --------             |  
|   |      |             |  
|   |Button|             |  
|   |      |             |  
|   --------             |  
|                        |  
|                        |  
--------------------------  
 Screen1 (Full screen)

When the user swipe the any part of the screen to left/right, the screen is changed to the next screen.

And when the user click the button on the screen, the button is clicked(for example, change color).
Of course, when the user click the empty are(Area B), nothing happened.

To implement this, I tried to make a topmost full-screen size simpletouchhandler.
And, this simpletouchhandler decided if left(right)-swipe is detected or not.
If not, the simpletouchandler called the DeflectCursor function, to hand over the event.

But, the problem is when user clicked the button in very short time.
The only pressed and released events are generated.
So, the DeflectCursor function is called in the released-event slot.

At that case, the simpletouchhandler receive the release event with AutoDeflected=True.
And, the touchhandler of Button received only the press-event.

So, What is the best solution to generate the full 'grab cycle'?

Thanks and best regards.
Jinho.
by
Dear Chris.

Thank you for your advice.

 

When I commented for you answer, your answer disappeared. TT

Do I ever make  a mistake?

 

-------------------------------------------------------------------------

I hope to not modify the code of ViewA,ViewB. (I hope to avoid adding the OnDrag to existing buttons)

So, I added the topmost simpleTouchHandler.

Of course, that solution is not perfect.

Is there any solution?

 

Thanks and best regards.

Jinho.
by
Hi Jinho,

I can still see my answer below your post. :-)

I have answered to your comment there as well.

1 Answer

0 votes
by

Hi,

there is not only one way to do this.

Following I will explain what I did, when I needed something like this last time:
I had an ApplicationView and two different views (lets say ViewA, ViewB) that contain different buttons etc. The ViewA and ViewB are in foreground. When a button is used it reacts as expected. If I slide or swap while the button was in focus, the button deflects the cursor to the ApplicationViews SlideHandler.

In detail:
The ViewA and ViewB get a Property called e.g. GlobalSlideHandler (type: Core::SlideTouchHandler).
The Buttons in ViewA and ViewB needs an onDrag slot with following content:

GetRoot().DeflectCursor( GlobalSlideHandler, <0,0> );


Order in the ApplicationView:
ViewA ( set SlideTouchHandler for GlobalSlideHandler )
ViewB ( set SlideTouchHandler for GlobalSlideHandler )
Outline ( set SlideTouchHandler )
SlideTouchHandler (to slide between ViewA and ViewB)

Download:
Sample Project

HTH.
Chris

by
Dear Chris.

Thank you for your reply.

 

In your approach, it seems all buttons to have the drag property.

Is there any solution without modifying  the existing code?

 

Order of handlers.

 

SomeTouchHandler,( which handles the swipe and deflectcursor. )

ViewA ( with normal button)

ViewB ( with normal button)

 

Thanks and best regards.

Jinho.
by
Hi Jinho,

Your idea using a TouchHandler on top most, sounds good, but in my opinion this top layer handler cannot handle differences between "user just pressed" or "user is about to drag", because both touch variants starts with the pressing state.

Example:
Whenever a user touches, the onPress of your SimpleTouchHandler is fired. Now, your TouchHandler has to decide to deflect the cursor to e.g. the button or to the SlideTouchHandler. If the cursor is outside the button-area, you can deflect to the SlideTouchHandler, ok so far. But, when the curosr is inside the button-area, the SimpleTouchHandler deflects the cursor to the button. After the button gets the grab-cycle, the SimpleTouchHandler cannot get the grab cycle back. With other words: The SimpleTouchHandler will never be able to fire the onDrag, because the handler needs to decide to deflect onPress already.

You could change the reaction of the top most SimpleTouchHandler from onPress to onRelease. But then your buttons will only react to onRelease (no on-press feedback possible). You could try if this a "possible solution" for your project.

Chris
by
Dear Chris.

 

Because I hope to handle a long key, my buttons react on release.

So, my question is how to handle the short-time key touch.

Ideally, I hope to this event fire the onRelease of button.

But, as I mentioned, at short key press, DeflectCursor can fire only the onPress of button.

 

At short key press, neither  onHold nor onMove occur. If user click a button shortly, topmost simpleTouchHandler receive only onPress and onRelease. Obviously, this click is for button. So, I hope to the simpleTouchHandler hand over this event to button.

I tried to use FIndViewAtPosition with Touchable filter. After recursive search, and call the onRelease slot of found touch handler. But I hope to use the mosaic framework. Is the user call of Core.Root.DriveCursorHitting  possible?

 

Thanks and best regards.

Jinho.
by

Hi Jinho,

if you really do not want to modify the current buttons or views and you want to control everything via a "topmost simpleTouchHandler", then you need some logic for it. This handler needs to be able to evaluate everything for your GUI.

In the logic (~state machine) you need to differ a "short click" (onPress followed by onRelease), a "longer one" (onHold or onPress for greater than X00ms) and also you need to check for onDrag and optionally onRelease (if you don't want to use the grab cycle). In each case you need a timer to ensure the state.

For example: 
If a user just clicks on an area for some less ms (checked via timer), this should evaluated as a short click. Then you have some options: 

  • DeflectCursor to the area's item (e.g. button), which you can find via e.g. FindViewAtPosition( null, cursor-point, Core::ViewState[ Visible ] ); if you don't know it.
  • As you have asked, yes, you can also emulate release- and press-touches. For example you could create a finger-timer that hits at beginning e.g. DriveCursorHitting( true, 0, cursor-point ); for onPress and after like 500ms the same call again - but "false" instead of "true" for onRelease.
  • Because you are writing your own toch handler logic, you could also call the e.g. buttons onAction methods directly via its objects.

Hope this helps!

Chris

by

Maybe you can also find some inspiration here:

Touch events and the grab cycle

Combine several touch handlers together

Property: RetargetCondition

The documentation itself and some of the functionality are brand new with the mosaic library/embedded wizard v.8.10.

by
Thank you very much.

I had better upgrade my embeddedwizard.

Embedded Wizard Website | Privacy Policy | Imprint

...