Global Event Listeners for all Views in a ViewNavigatorApplication

Hello,
As the subject states, I have a ViewNavigatorApplication and I am trying to set up a "global" event listener for all views. Which I am able to do, however I am having problems...
In my first view, I assign this listener:
NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, handleKeys);
And I also have this function:
public function handleKeys(event:KeyboardEvent):void {
     if (event.keyCode == Keyboard.MENU) {
                    trace("menu pressed");
                    navigator.pushView(MainMenuView);
This works fine from the first view. But when I switch views, I get an exception on pushView (navigator is null). I think I understand why, so what is the best practice for something like this? How can I get access to the spark component navigator from that function when called from a different view? Or is there a better way to go about this?
Thank you!

Try putting the code in the main mxml:
<?xml version="1.0" encoding="utf-8"?>
<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    firstView="home"
    applicationComplete="init()" >
    <fx:Script>
        <![CDATA[
            private function init():void {
                this.addEventListener(KeyboardEvent.KEY_DOWN, handleKeys);
            private function handleKeys(event:KeyboardEvent):void {

Similar Messages

  • Global object visible for all sessions in WebDynpro application

    Hello everybody,
    in a normal java web application you have the possibility
    to put an object into the servlet context.
    This object is visible for all sessions(e.g. some configurations or global settings for the
    web application).
    Now my question:
    Is there a possibility in a WebDynpro application to put such an object into a "global context" visible for all sessions?
    So I am looking for a container in WebDynpro which has
    the same behaviour like the servlet context in a web application.
    Thank you for your ideas an suggestions.
    Greetings
    Anton

    Hi Anton,
    To make an Variable Global ,you have define variable at various levels based on Usage.
    1)Ex: If you want to define Variable between two different Components . when A component is embedded into B Component then you have to define at Component Interface level and Mapping has to be Defined.
    2) If you want to make Variable to be used within the component among the Iviews ,then you can define at Component Controller or Custom Controller and Mapping has to be defined at Iview Level.
    3) If you want to use Variable between two Webdynpro Iviews then you have define the eventing mechanism to pass the values among the EP Webdynpro Iviews.
    Hope this answer helps you.
    Thanks
    Madhan

  • How can i set a global error page for all error cod

    how can i set a global error page for all error code?
    i don't want to leave a long list in the web.xml file.could any one help me?
    thanks

    If u have a common Error JSP named as ErrorPage.jsp
    You need to have the following piece of code in the JSP as :
    <%@ page isErrorPage ="true"%>
    This makes it as the Common Error Page for the Application. Now all you need to do is from other JSP's throw the Exception to teh container. The container will redirect to this Page and process accordingly.
    Thanks and regards,
    Pazhanikanthan. P

  • Global event handler for preinitialize

    Is there anyway to add a global event handler on the
    components preinitialize event?
    What I need to do is to be able to enable / disable, and show
    / hide component dynamically based on a access list. My plan was to
    have a global event handler that listens to the preinitialize
    event, at that time, checks if the user has access to the component
    or not. If not, I'll disable / hide the component.
    What I did so far is:
    in my main app.mxml file, I have:
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    preinitialize="preinit(event)"
    so the preinit() function is invoked on the app's
    preinitialize event.
    Then I have the preinit() function (see attached code below).
    However, it does work as there is no trace message printed.
    I changed to use KeyBoardEvent.KEY_DOWN and that seems
    working when I press any key.
    I also tried to use the app.stage.addEventListener() but the
    stage object is null in the preinitialize event.
    Thanks in advance for your help.

    Thank you for follow up on my question.
    I do know these two properties. But that does not solve the
    problem. Let me explain it with an example.
    That's say, when the user logs in, I loads the access list.
    Then the app displays a panel with some form entries. If I am able
    to register a global event listener for the component
    initialization events, I can check the permission and optionally
    hide some components. Otherwise, I would need to programmatically
    travels my component tree to evaluate each component individually
    to set there visible/includeInLayout properties, which is error
    prone.
    The problem is that the component is visible to one user but
    would be hidden to another, so it can not be set at the design
    time.
    The approach I am using right now is to extend the default
    components to add an event listener. But I'd like to know if it is
    possible to register a global event listener to be notified when
    any component is created. As my first post says, I tried to use the
    systemManager and listen to the PREINITIALIZE event, but that
    didn't get always get invoked.

  • Event Receiver for all Page Libraries in a Site Collection

    We have a single site collection with many different page libraries.  I'd like to create a single event receiver for ALL page libraries in the site collection (850- Page Library).  Can you do this?
    The event receiver will essentially remove/expire something we have stored in the System.Web.HttpRuntime.Cache.  We are caching the content in the Page Library and would only like to expire the cache when a new page or change is performed on some
    content in the page library.

    Hi,
    We can create a new feature and add an event receiver to the feature for all Page Libraries.
    For more information, you can see the link below:
    http://msdn.microsoft.com/en-us/library/ee231604.aspx
    Here are two similar threads for you to take a look at:
    http://sharepoint.stackexchange.com/questions/37555/how-to-add-event-receivers-to-all-the-lists-in-a-site-collection
    http://social.technet.microsoft.com/Forums/en-US/f1297543-9035-49d6-9299-d82f546eeddd/event-receiver-for-specific-list-fires-for-all-lists-on-site-collection?forum=sharepointcustomizationprevious
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Dennis Guo
    TechNet Community Support

  • Material creation for All VIEW using BAPI Function modules

    Dear All,
                 I want to create materials for all views using BAPI F.Ms. By using BAPI_MATERIAL_SAVEDATA i have extended materials for for only specified views. now my requirement is to create Material with All views including Classfication view also. For this i found BAPI_OBJCL_CREATEFM.
             Tell me that shall i use both Fm's at time to create material.Will it work? According to my knowledge we need to create Characters first ,then we should  assign this character to this class, then while creation of material we should select this class .
            so pls guide me the procedure to follow for both FM's .
    Note : Pls don't suggest me LSMW OR BDC procedure.
    regards,
    Prashanth Maturu.

    Hi prashanth,
    U can use both the FM. using BAPI_MATERIAL_SAVEDATA u can create all the views and for classification view use BAPI_OBJCL_CREATE. before assigning class to material u hve to make sure that the characteristics are uploaded and is attched to the class using transaction CL03.
    Regards,
    Anil N.

  • Is there a way to clear ALL event listeners, stop all movie clips, etc?

    Is there a syntax for this?
    I have a movie that has 15 frames. Each frame has embedded movie clips within movie clips, tons of animations and event listeners. None is needed except when they are on the stage, on the frame. However, the animations continue even when the frame is left.
    For instance, I have a frame that has a dynamically rendered animation of leaves falling from a tree. When the frame is left, the leaves continue to fall.
    There are many instances of this type of thing happening.
    Ideally, I would love to just be able to clear everything when a new frame is loaded, since none of the animations or event listeners need to carry over from one frame to another.
    Is there a way to do this without the thousands of lines of code it would take to manually remove every single animation and event listener and sound, etc, from the stage?
    Thanks so much!!
    Amber

    you have to manually do that.
    or, you could convert each frame to a swf.  load each swf when needed and, if you're publishing for fp 10+, you can apply unloadAndStop() to kill all streams in the loaded swf and ready those assets for gc.

  • Specific Event ID for all computers

    Hi,
    We are using SCCM 2012 SP1. We need to know, how many users in our environment used remote assistance from their desktop to which other computers. Is there any way of discovering this using SCCM 2012. The built-in report in SCCM 2012 [Remote Control- All
    remote control information] provides information related to remote assistance done from inside the SCCM Server itself.
    Or, is there any way I can get the information of that particular Event ID [For remote assistance] from all the computers, which a user used to provide remote assistance to other computers in our domain.
    Regards,
    Hasnain.

    Remote Assistance is an OS feature simply referenced in the ConfigMgr console thus ConfigMgr doesn't audit its use in any way.
    A quick web search turned up this though which adds the OS level auditing info from the event log to the hardware inventory process of ConfigMgr:
    http://myitforum.com/cs2/blogs/jgilbert/archive/2007/08/08/inventorying-remote-assistance-requests-and-connections.aspx . You'll have to adapt it for 2012 as there are some differences although the principles are identical.
    Jason | http://blog.configmgrftw.com

  • Culled 3D object not transparent for all views/translations

    This code displays a tube that is stored in a VRML file.  I modified the 'open WRL file' to import the object as a single color (green) with a alpha (transparency) value of 0.5.  The vi also draws an opaque sphere.  The sphere can be seen through the tube, but for only certain locations/viewpoints.
    This discussion (http://forums.ni.com/ni/board/message?board.id=170&thread.id=280607&view=by_date_ascending&page=2) suggests duplicating the object and culling the front/back faces, which I've also done.
    Please look at the code.  '3D Control Main' is the main vi.  You should notice as the sphere moves through the tube that transparency dissapears.  All I need is for the transparency to remain constant.  Any suggestions are welcome.
    -Joe
    Attachments:
    3D tube.zip ‏375 KB

    Hi peabody,
    I've tried running your code, but I'm missing C:\Documents and Settings\Smile\My Documents\My Pictures\crosshatch.jpg file. Also, is it possible for you to simpify your code to illustrate the issue better?
    Regards,
    Stanley Hu
    National Instruments
    Applications Engineering
    http://www.ni.com/support

  • How do I lock in a font size for all viewing

    I created a website that looked great on my laptop, my house desktop, my Blackberry and even my Kindle. But the guy that I made it for has his internet browsers set at font size 18 so it looks horrible. I didn't realize that my computers are all set at 14.  I'm assuming that my phone and Kindle are set at 14 as well since everything lined up right. So I went back and set my internet browser at 18 and redid the pages to match.
    My question is how do I create pages with universal size fonts so that this doesn't happen and so that I don't have to change my font sizes everytime I work on this particular site?  It looks so tiny when I change back to 14!
    http://www.steveberlinmusic.com/projects.html
    Thank you!
    Dee Dee

    One issue to clear up might be the redundant styling of text through CSS and through HTML. If you are defining size in CSS, there is little need to also define a -1 font size in the HTML.
    You might experiment with alternate measures of font size in the CSS. There is more than just 'px'.

  • How do I make a global helper servlet for all applications?

    I am running about five different web applications in tomcat 5.0.24. They all need to do some spelling correction from time to time. I have a spelling correction API and a bunch of dictionaries, etc. so I can do it just fine. The problem is, I don't want each application to create all the dictionaries because then I end up with five spell checking programs and five dictionaries being accessed (basically I am exactly repeating myself five times and I start running out of memory). I would like to have a servlet that just sits waiting all the time and which any other servlet or JSP in any of my web applications can quickly dash of a spell check request to at any time.
    How do I do this?
    I think I need to write a servlet since I want to run it in tomcat and access it from my webapps, but it might not need to be a servlet since it is never actually contacted from a browser and will not ever write anything back to the client. I just need my other servlets and JSPs to access the spell checking functionality from time to time.

    I'd say tomcat/common/lib is a good guess for where you'd put the class's jar file, but I don't use Tomcat so I can't say for sure. As for how to only have one dictionary, you need a singleton class, i.e. one that only permits one instance of the class to be created. Like this, if you haven't heard of it:public class SpellChecker {
      // create a single SpellChecker here:
      private SpellChecker theInstance = new SpellChecker();
      // don't let anybody else create another one:
      private SpellChecker() {}
      // provide a method for returning the single instance:
      public static SpellChecker getInstance() {
        return theInstance;
      // remaining methods go here
      // watch out for synchronization issues
    }To get hold of the spell-checker, just doSpellChecker.getInstance()PC&#178;

  • Global volume control for all sounds in a swf

    Does anyone know of a way to adjust the volume of all the sounds in a swf?  I'm looking to build a volume controller that changes the audio level of the swf.
    Thanks!

    I used:
    SoundMixer.soundTransform = new SoundTransform(0);
    and that mutes all sounds in my swf.

  • Event listeners for digital pens

    How do I capture events from a digital pen? I want to build an application that takes input from such pens/tablets, but have no idea how they work. My guess is that they create mouse events and that I can use MouseListener. The spec of the pen shows 1024 pressure levels. How do I get the pen pressure? Is there a DigitalPenListener class?

    Yes - when you click on the array/group widget in the form editor, there's an 'Event Listener' section with a property called "Method Invoked".
    I think you've figured this out on your own, but If you have trouble seeing a method in the dropdown, create a method that has one argument of type Fuego.Util.GroupEvent. If you look at this class, you can see the various event types that can be received (ADD, INSERT_DOWN, INSERT_UP, REMOVE, and REMOVE_LAST).
    Dan

  • Global item for all applications in a workspace

    Hi All,
    Is there a way to set a global item available for all applications in a workspace?

    Sabiha,
    I know this is a bit late, but here's what I did. This answer spans your question a bit but may be helpful to others.
    I have a dev, test, and prod environment so we have difference values depending on the instance. When moving an app from dev to test I don't want to have to modify any substitution strings since that can become a pain and possibilities of someone forgetting something is high.
    1- Great a table called global_values, which has a value_name, and value
    Let's say you wanted to store an email address: admin_email...
    2- Make sure to insert into global_values ('ADMIN_EMAIL, '[email protected]');
    3- For each application you have, create an application item called G_ADMIN_EMAIL
    4- For each application create a process (on login) called: Set Global Values. In this use the util:
    HTMLDB_UTIL.SET_SESSION_STATE (
    p_name => 'G_ADMIN_EMAIL',
    p_value => <function to get the global value> );
    4(extra): For one application item this is ok, but to make it even better, just create a function that will set all the application items so you don't have to change this in all your applications.
    The advantage with all this is that the data is stored in the DB and will help you move from instances without any errors. The disadvantage is that it'll be a slight performance hit since you're calling a function for each user login. You'll also have to add an application_item for each of your applications....
    Martin

  • Global TOp for all the methods

    HI all,
    I am creating a class, And creating 10 methods inside that class.
    i want to use a single TOP program for data declearation which shud applicable in whole class, so that automatically it eccepts all the methods.
    any idea HOW to create that global data declearation for all methods.
    thanks,
    jo

    Hello Jo,
    In OO-Concept the class variables (Instance or Static) are always visible to the methods.
    If you are different classes, and you want to share variables between them, I would recommend you to use a super class or an interface for the sharing functionalities. Of course these concepts are not exactly for sharing variables. But nevertheless it might help you to solve your problem.
    P.S. I just wanted to simplify the context a little. Naimesh Patel deserves the credit, since he has given the right answer
    Greetz
    G.Fendoglu

Maybe you are looking for