Change function of Handy back button in the App
-
jonas.rauschTeilnehmer
Has successfully completed the online course Introduction
Has successfully completed the online course Intermediate (200)
Has successfully completed the online course Advanced (300)vor 5 Jahren, 9 Monaten #18890::Hi Ralf,
The Device Button events like “back” and “home” can be detected and overwritten via JQuery/JS:
You can add this line of code to the onInit event pf your first screen:
document.addEventListener(‘backbutton’, function(){
//do stuff here
}Be Aware that overwriting the event will supress the native functions of the button, if you want to exit the app, you will need to code that yourself.
jonas.rauschTeilnehmer
Has successfully completed the online course Introduction
Has successfully completed the online course Intermediate (200)
Has successfully completed the online course Advanced (300)vor 5 Jahren, 9 Monaten #19467::document.addEventListener("backbutton", onBackKeyDown, false); function onBackKeyDown() { // Handle the back button //alert('Back Button is Pressed!'); if ("{actual Screen}"=== "Main") { console.info('close pressed'); // Backbutton -> close App } else { console.info('back pressed'); // NavTo history.back or backtoMain } }This works, but i don´t know how to handle the if-command and Backbutton in SAPUI…
Need help how i ask for actual Screen and the commands how i go history (window) back and close app
DinkelModerator
Has successfully completed the online course Introduction
Has successfully completed the online course Intermediate (200)
Has successfully completed the online course Advanced (300)
Has successfully completed the online course Basics (100)
jonas.rauschTeilnehmer
Has successfully completed the online course Introduction
Has successfully completed the online course Intermediate (200)
Has successfully completed the online course Advanced (300)vor 5 Jahren, 9 Monaten #19473vor 5 Jahren, 9 Monaten #19489::Ok, this Script works,
document.addEventListener("backbutton", onBackKeyDown, false); function onBackKeyDown() { var curr_page = sap.ui.getCore().byId("Application").getCurrentPage(); console.info(curr_page.getId()); if (curr_page.getId() === "PAGE1") { console.info('close pressed'); window.navigator.app.exitApp(); // OK } else { console.info('back pressed'); // window.navigator.app.backHistory(); // <no action this.navBack(); // Uncaught TypeError this.navBack is not a function // window.navigator.app.navBack(); // Uncaught TypeError window.navigator.app.navBack is not a function } }but this.navBack(); and the other variations doesn´t.
Any Idea why?
DinkelModerator
Has successfully completed the online course Introduction
Has successfully completed the online course Intermediate (200)
Has successfully completed the online course Advanced (300)
Has successfully completed the online course Basics (100)vor 5 Jahren, 9 Monaten #19490::You have to bind this.
document.addEventListener("backbutton", onBackKeyDown.bind(this), false); function onBackKeyDown() { var curr_page = sap.ui.getCore().byId("Application").getCurrentPage(); console.info(curr_page.getId()); if (curr_page.getId() === "PAGE1") { console.info('close pressed'); window.navigator.app.exitApp(); // OK } else { console.info('back pressed'); // window.navigator.app.backHistory(); // <no action this.navBack(); // Uncaught TypeError this.navBack is not a function // window.navigator.app.navBack(); // Uncaught TypeError window.navigator.app.navBack is not a function } }
Ansicht von 10 Beiträgen – 1 bis 10 (von insgesamt 10)
You must be logged in to reply to this topic.