1. #1
    Sencha User
    Join Date
    Dec 2010
    Posts
    6
    Vote Rating
    0
    orgreeno is on a distinguished road

      0  

    Default Global keypress

    Global keypress


    Using Designer 2, what is the best way to listen for a keypress event for the entire app? Can I add a keypress listener to the main panel? Or listen for keypress DOM events?

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    8,185
    Vote Rating
    63
    aconran is just really nice aconran is just really nice aconran is just really nice aconran is just really nice aconran is just really nice

      0  

    Default


    Probably subscribing to the key event on the body.
    eg
    Ext.getBody().on

    You could set this up in your Application launch method.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  3. #3
    Sencha User
    Join Date
    Dec 2010
    Posts
    6
    Vote Rating
    0
    orgreeno is on a distinguished road

      0  

    Default


    Should this fire the alert?
    launch: function() {
    alert("launched");
    Ext.create('MyApp.view.main_panel', {fullscreen: true});
    }
    The app loads but the alert does not fire.

    build 355
    sencha touch project

  4. #4
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    8,185
    Vote Rating
    63
    aconran is just really nice aconran is just really nice aconran is just really nice aconran is just really nice aconran is just really nice

      0  

    Default


    It should. I just tested a simple application by doing the following:

    Start a touch 2.0 project
    Drag out a Panel
    Add a launch method to Application
    add an alert to the launch method

    Save and preview the project in the browser.

    the code generated for Application was:
    Code:
    Ext.Loader.setConfig({
        enabled: true
    });
    
    Ext.application({
        views: [
            'MyPanel'
        ],
        name: 'MyApp',
    
        launch: function() {
            alert('launch');
            Ext.create('MyApp.view.MyPanel', {fullscreen: true});
        }
    
    });
    Aaron Conran
    @aconran
    Sencha Architect Development Team