Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Desktop, Mobile and non-browser Environments > AIR (Apollo)

Reply
 
Thread Tools Rate Thread Display Modes
Old 04-08-2008, 03:34 PM   #1
ABM
Registered User
 
Join Date: Mar 2008
Posts: 15
Default Prevent closing air app with cmd+w shortkey

hi!
i was wondering if there is any possibility to prevent closing the air app if the user click on command+w in his keyboard (Mac).

Regards,
Adil
ABM is offline   Reply With Quote
Old 04-10-2008, 01:24 PM   #2
ABM
Registered User
 
Join Date: Mar 2008
Posts: 15
Default

Hi All,

I have the solution, and it works now for mac(cmd+W or cmd+Q) and win(alt+F4).
ActionScript Code:
<?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">   <mx:Script>     <![CDATA[       import mx.containers.Canvas;             private var key_down: Boolean;       private var os: String;             private function init(): void       {         os = (Capabilities.os.search("Mac") >= 0) ? 'Mac' : 'Win';         addEventListener( Event.CLOSING, onClosing );         addEventListener( KeyboardEvent.KEY_DOWN, onKeyDown );         addEventListener( KeyboardEvent.KEY_UP, onKeyUp );       }             private function onKeyDown( event: KeyboardEvent ): void       {         key_down = (os == 'Mac') ? event.commandKey : event.altKey;       }             private function onKeyUp( event: KeyboardEvent ): void       {         key_down = false;       }             private function onClosing( event: Event ): void       {         if( key_down && ( navigator.numChildren > 0 ) )         {           navigator.removeChild( navigator.selectedChild );           event.preventDefault();         }       }             private function addNewTab(): void       {         var canvas: Canvas = new Canvas();         canvas.percentWidth = 100;         canvas.percentHeight = 100;         canvas.label = 'Tab ' + ( navigator.numChildren + 1 );         canvas.setStyle( 'backgroundColor', uint( Math.random() * 255 ) << 16 | uint( Math.random() * 255 ) << 8 | uint( Math.random() * 255 ) );                 navigator.addChild( canvas );         navigator.selectedIndex = ( navigator.numChildren - 1 );       }     ]]>   </mx:Script>   <mx:VBox bottom="10" top="10" left="10" right="10">     <mx:HBox width="100%">       <mx:Button label="Add New Tab" click="addNewTab()"/>     </mx:HBox>     <mx:TabNavigator id="navigator" width="100%" height="100%">       <mx:Canvas label="Tab 1" width="100%" height="100%">       </mx:Canvas>     </mx:TabNavigator>   </mx:VBox>   </mx:WindowedApplication>

Best Regards,
Adil
ABM is offline   Reply With Quote
Old 04-11-2008, 08:09 AM   #3
beantickler
Registered User
 
Join Date: Apr 2008
Posts: 5
Default

The only bit of relevence is:...

addEventListener( Event.CLOSING, onClosing );
private function onClosing( event: Event ): void
{
event.preventDefault();
}
beantickler is offline   Reply With Quote
Old 04-11-2008, 08:18 AM   #4
ABM
Registered User
 
Join Date: Mar 2008
Posts: 15
Default

Hi, yes is true,

But this small app colse the tabs of the TabNavigator in thesame way as firefox does...

Regards,
Adil
ABM is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
AIR app question. Antonios AIR (Apollo) 1 04-03-2008 10:25 AM
Trouble with HelloWorld air app... Assertnfailure AIR (Apollo) 0 03-08-2008 02:27 AM
Close and drag for AIR app djones AIR (Apollo) 8 02-28-2008 05:38 PM
Maximize and minimize Air app lg101 AIR (Apollo) 1 02-18-2008 01:39 PM
Prevent Menu Closing on Click (Override default behaviour?) mskibbz Components 1 10-04-2005 05:04 AM


All times are GMT. The time now is 06:27 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.