Disabling ‘Back’ button for flex mobile View

// April 14th, 2013 // Hardware

Despite many articles over the network – it is very easy to disable the Back button for any mobile View.
You don’t have to override anything..all you have to do is to define backKeyPressed event in your View declaration and call event.preventDefault() method. Here is an example:


<s:View
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
title="My View" backKeyPressed="onBackPRessed(event)" >

And here is the method implementation:

protected function onBackPRessed(event:FlexEvent):void {
event.preventDefault();
}

 

This is very useful when you want to disable back button for some view(s). Example you have loged in view which is after the register view..you don’t want your app users to go to register again after they press the back button.. (which is the automaticly popped view)

Leave a Reply

*