[Project_owners] capturing keypress and handing to default listener

eric.jung at yahoo.com eric.jung at yahoo.com
Mon Sep 25 17:31:59 EDT 2006


Thanks, but I already tried exactly that. Take a look at the code in my original post where wrote "I've also tried the non-DOMEvent way:"

----- Original Message ----
From: Ramiro Aparicio <frisco82 at gmail.com>
To: Mozdev Project Owners List <project_owners at mozdev.org>
Sent: Monday, September 25, 2006 5:50:55 PM
Subject: Re: [Project_owners] capturing keypress and handing to default listener

I really don't understand the event model but I think there can be at most 1 event listener per layer (1 on a cell, 1 on the parent table, ... 1 on the document) but I can be completely wrong.

My aproach with that is: 

    var old_onmouseup = window.onmouseup;
    window.onmouseup = function (e) { 
            foxgameOnMouseUp(e); 
            if (typeof old_onmouseup == "function") old_onmouseup(e);
            }; 
    var old_onkeyup = window.onkeyup;
    window.onkeyup = function (e) { 
            foxgame_onKeyUpCheck(e);
            if (typeof old_onkeyp == "function") old_onkeyup(e);
            };
 
Everything on the onLoad event listener, I needed to call the previous listener allways but it is easy to change, this is working between extensions (was a fix to avoid incompatibility with autocopy) but I don't know if it works with a listener added in the web code. 

On 9/25/06, Eric H. Jung <eric.jung at yahoo.com> wrote: Hi,

I capture keypress events in a dialog. If the keypress is a number, my listener performs an action. If it's not a number, I want the default keypress event listener to process the event. No matter what I've tried, I can't get the default event listener to process the event once my listener has the keypress. 

I've tried window.addEventListener("myListener", onKeyPress, false), window.addEventListener("myListener", onKeyPress, true) where myListener is:

function myListener(evt) {
   if (!isNaN( evt.charCode)) { // if user typed a number, select the corresponding tree row
      var row = parseInt(evt.charCode-KeyboardEvent.DOM_VK_0)-1;
      row <= accountsTree.view.rowCount-1 && accountsTree.view.selection.select (row);
  // Shouldn't other event listeners now be called?
}

I've also tried the non-DOMEvent way:

var origOnKeyPress;
function onLoad() {
  origOnKeyPress = window.keypress;
  window.onKeyPress  = myListener;
}

function myListener(evt) {
    if (!isNaN(evt.charCode)) { // if user typed a number, select the corresponding tree row
      var row = parseInt(evt.charCode-KeyboardEvent.DOM_VK_0)-1;
       if (row <= accountsTree.view.rowCount-1)
          accountsTree.view.selection.select(row);
      else
          origOnKeyPress(evt);
    }
     else
          origOnKeyPress(evt);
}

Thanks for any ideas, 
Eric


_______________________________________________
Project_owners mailing list
Project_owners at mozdev.org
 http://mozdev.org/mailman/listinfo/project_owners




-- 
Hasta Otra 

Ramiro Aparicio

--------------------------------------------------------------------------------- 
Webmaster de http://gs151.tk y http://www.climaxsl.es
Desarrollador de FoxGame http://foxgame.mozdev.org_______________________________________________
Project_owners mailing list
Project_owners at mozdev.org
http://mozdev.org/mailman/listinfo/project_owners




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mozdev.org/pipermail/project_owners/attachments/20060925/9367bc7d/attachment-0001.htm


More information about the Project_owners mailing list