Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8812095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:31:35+00:00 2026-06-14T03:31:35+00:00

I am developing a Sencha Touch 2 App on an android device. My android

  • 0

I am developing a Sencha Touch 2 App on an android device. My android device is not a normal mobilephone, so it has hardware-keys, too. Can I react on an keydown, keyup or keypress event in sencha touch? And how? One of them would be enough.

If it’s helpful: In normal JavaScript the key can be handled by onkeydown Listener and the keyCode is 0.

[Update]
I work on this tutorial for sencha touch. I have made all steps and it works fine. Now I want to catch the hardware key, how I discribed above. I put an addEventListener as in Handle Android Hardware….

So my code looks like:

Ext.application({
    name: "NotesApp",
    models: ["Note"],
    stores: ["Notes"],
    controllers: ["Notes"],
    views: ["NotesList", "NotesListContainer", "NoteEditor"],
    launch: function () {           
        var notesListContainer = {
                xtype: "noteslistcontainer"
        };
        var noteEditor = {
                xtype: "noteeditor"
            };
        Ext.Viewport.add(notesListContainer, noteEditor);

        document.addEventListener("keydown", Ext.bind(onKeyDown, this), false); 

        function onKeyDown(e) {     
           // you are at the home screen
           if (Ext.Viewport.getActiveItem().xtype == notesListContainer.xtype ) {
              alert('aha'); // give out 'aha'
                  //  LABEL1

           } else {}

        }
    }


});

How can I call a function on position LABEL1. The function, which I want to call, is in the class controllers.Notes and its name is onNewScanCommand:

Ext.define("NotesApp.controller.Notes", {

extend: "Ext.app.Controller",
config: {
    refs: {
        // We're going to lookup our views by xtype.
        notesListContainer: "noteslistcontainer",
        noteEditor: {
            selector: 'noteeditor',
            xtype: 'noteeditor',
            autoCreate: true 
       }
    },
    control: {
        notesListContainer: {
            // The commands fired by the notes list container.
            newNoteCommand: "onNewNoteCommand",
            editNoteCommand: "onEditNoteCommand",
            newScanCommand: "onNewScanCommand"
        }
    }
},
onNewScanCommand: function () {
    console.log("onNewScanCommand");

    var now = new Date();
    var noteId = (now.getTime()).toString() + (this.getRandomInt(0, 100)).toString();

    var newNote = Ext.create("NotesApp.model.Note", {
        id: noteId,
        dateCreated: now,
        title: "",
        narrative: ""
    });

    // here I call a function in PhnoeGap, then this call a nativ function
    scan("echome", function(echoValue) {
        newNote.set("title", echoValue.scanNummer);
        newNote.set("narrative", echoValue.scanType);
    });



    var notesStore = Ext.getStore("Notes");
    /*
    if (null == notesStore.findRecord('id', newNote.data.id)) {
        notesStore.add(newNote);
    }*/
    notesStore.add(newNote);

    notesStore.sync();

    notesStore.sort([{ property: 'dateCreated', direction: 'DESC'}]);

    //this.activateNotesList();
},
// Base Class functions.
launch: function () {
    this.callParent(arguments);
    Ext.getStore("Notes").load();
    console.log("launch");
},
init: function () {
    this.callParent(arguments);
    console.log("init");
}

});

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:31:36+00:00Added an answer on June 14, 2026 at 3:31 am

    I have the solution!
    My controller is watching for Events. The Events were fired in the view NotesListContainer.

    I add an id to my variable notesListContainer and so I can get the object of NotesListContainer and fire myevent newScanCommand

    Ext.application({
            name: "NotesApp",
            models: ["Note"],
            stores: ["Notes"],
            controllers: ["Notes"],
            views: ["NotesList", "NotesListContainer", "NoteEditor"],
            launch: function () {
    
                var notesListContainer = {
                    id: 'nlistcontainer',
                    xtype: "noteslistcontainer"
                };
                 var noteEditor = {
                    xtype: "noteeditor"
                };
                Ext.Viewport.add(notesListContainer, noteEditor);
    
                document.addEventListener("keydown", Ext.bind(onBackKeyDown, this ), false); 
    
                function onBackKeyDown(e) {
    
                    // you are at the home screen
                    if (Ext.Viewport.getActiveItem().xtype == notesListContainer.xtype ) {
    
                        //the solution
                        Ext.getCmp('nlistcontainer').fireEvent("newScanCommand", this);
    
                    } else {
                        this.getApplication().getHistory().add(Ext.create('Ext.app.Action', {
                            url: 'noteslistcontainer'
                        }));
                    }
    
                }
            }
    
    
        });
    

    So, this is my rescue: Ext.getCmp('nlistcontainer') 😉
    Maybe, it gives a better solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing Sencha-Touch 2.0 MVC based mobile web-app. Can you please tell me
I am developing an app using Sencha Touch 1.1.1. I would like to create
I'm developping an Android app based on Sencha Touch 2 and Phonegap Cordova. I've
We are developing an app with Sencha Touch 2 and PhoneGap 2.0 . We
I'm developing an app in Sencha Touch 2.0 that is supposed to parse JSON
Developing a Sencha Touch MVC app that pulls data from json store (thats set
I am developing Sencha-Touch 1.1.0 MVC based mobile web-app. Before that I had checked,
I am very new to sencha touch. I am developing an App using sencha.
I'm developing a Sencha Touch application that has multiple data stores. In order to
Hi Im developing a sencha-touch-2 app which will be embedded on iPhone UIWebview .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.