How to link to a screen with a click / tap anywhere on the current screen?
Application Type
Mobile
Service Studio Version
11.50.11 (Build 47949)

I'm building a super simple mobile only and client side only app that consists of two screens. When you start the app, the first (Main) screen displays an dynamically calculated expression over a full screen background picture. Tapping anywhere on the screen should transition to a second screen and on that second screen tapping anywhere should bring you back to the first (Main) one (effectively flipping between these two wherever you tap).

How do i make it that a tap anywhere on screen triggers a link to another screen?

I was looking for a way to get some invisible object layered on top of everything and link that, but have not found a plausible way of doing this within the framework so far. I have seen some similar questions in the forum, but most answers seem to come with a lot more baggage than what i am after. 

Happy to understand how to catch a global event of an "on Click" anywhere and script a transition to another screen, but i'm too unexperienced in the ServiceStudio and the framework to see how this would have to be put together cleanly.

Any help very much appreciated. Many thanks in advance!

mvp_badge
MVP

Hi Stefan,

In both the Screens - OnReady event handler flow, you will have to define a JS node which will

  • Register a click event handler on the div element with '.main-content' class 
  • On click event navigate to the second screen, vice-versa.

Refer to this Demo App


JavaScript Snippet: 

document.querySelector('.main-content').addEventListener('click', function() {
    $actions.NavigateToOSHappy(); // invoking screen action which does have the second screen as the action flow end-node
});


Refer to the attached .oml file


I hope this helps you!


Kind regards,

Benjith Sam

MobileLabNavigateJS.oml

Thanks Benjith, 

i'll try this. The sample app is helpful and does exactly what i'm after. Will report back.

mvp_badge
MVP

Sure, You're welcome :)

Thank you for the update.


Kind regards,

Benjith Sam 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.