Hi, thank you all for your tips, I managed to solve this one by overriding the tabnavigator by making some changes to the code posted by Manish earlier:

 

You'll have to extend the TabNavigator and override the selectedIndex setter.

<!-- MyTabNavigator.mxml -->
<?xml version="1.0"?>
<mx:TabNavigator xmlns:mx="http://www.macromedia.com/2003/mxml"
  xmlns="*">
  <mx:Script>
    var savedSelectedIndex:Number;
    public function set selectedIndex(value:Number):Void
    {
      savedSelectedIndex = value;
      tabBar.selectedIndex = super.selectedIndex;
      confirm("Are you really, really sure?");
    }
  </mx:Script>
</mx:TabNavigator>

In your alert handler you set the selectedIndex to the
savedSelectedIndex (if the user clicked OK).

-Mika

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Doodi, Hari - BLS CTR
Sent: 21. kesäkuuta 2005 17:17
To: 'flexcoders@yahoogroups.com'
Subject: RE: [flexcoders] TabNavigator gimmick

 

Hi All,
      I have same situations and unable to resolve.
      Can we request macromedia development/research group to provide a
new event called "changing" to TabNavigator controls which should fire
before "change" event and provide mechanism either go ahead or revert the
navigation. This way we can have total control of navigation and program
logic can decide whether to allow the user to navigate to next/other tab or
not.

Thanks!
Hari

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On
Behalf Of Mika Kiljunen
Sent: Tuesday, June 21, 2005 3:27 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] TabNavigator gimmick

Thanks Scott, but the problem is : "Unknown attribute 'click' on
mx.containers.TabNavigator".

So there is no click event on TabNavigator, I tried placing it on
change-event but it does not affect it if set selectedIndex=x, since change
seems to be fired before the change actually occurs, so tabnavigator is
going to change the tab after the event is handled anyway (so if I set it on
change to something, the tabnavigator sets it anyway to what it was supposed
to set to when the tab is clicked)... :[

-Mika

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On
Behalf Of Scott Barnes
Sent: 21. kesäkuuta 2005 10:11
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] TabNavigator gimmick

subscribe to the TabNavigators "click" event. From here, execute a
validation routine based   on the last known tab clicked (ie default
is tab0, then if user clicks tab1, then update a var to indicate
such).

Validate that tab, if it fails, then simply fire an exception routine
(ie popup) and selectedIndex = failedTab.

The end-user may experience a "flicker" between the two tabs based on
how long it takes to compute the validation routine.

this is the "quick and easy" way. If you want to prevent a user from
accessing the tab, then you may have to extend the TabNavigator and
over-ride the various methods associated to that class. I can't
remember off the top of my head what the TabNavigator uses in terms of
click, but i'd bet the farm it uses SimpleButton.

I'd love to post the code for code, line by line here but i'm a bit
swamped at present but the above is based on theory (especially if it
works similiar to the Accordion)

On 6/21/05, Mika Kiljunen <[EMAIL PROTECTED]> wrote:


>
> Hi,
>
> I could use some help with tabnavigator. I have a TabNavigator that has 3
> tabs on it. When the user clicks tab one and edits some data on the tab
view
> AND then clicks tab two, I should be able to stop this and go back to tab
> one and force the user to save data or at least to warn to save the edited
> data before going to tab two. Is there a way to do this? So basically I
need
> a way to catch the user's click on tab two (haven't figured out where) and
> then "cancel" the tab change event...
>
>  
>
> -Mika
>  ________________________________
>  Yahoo! Groups Links


> To visit your group on the web, go to:
> http://groups.yahoo.com/group/flexcoders/
>  
> To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
>  
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


--
Regards,
Scott Barnes
http://www.mossyblog.com
http://www.flexcoder.com ("Waiting for FLEX NCL to arrive")



Yahoo! Groups Links








Yahoo! Groups Links








Yahoo! Groups Links

Reply via email to