Loading ...
Sorry, an error occurred while loading the content.

RE: [ydn-javascript] Multiple modal dialogs with KeyListener

Expand Messages
  • Satyen Desai
    Hi Christian, If you re still looking for a solution for this: a). Have you tried using the OverlayManager, to keep track of the currently focused dialog.
    Message 1 of 2 , Jul 3, 2008
      Hi Christian,
      If you're still looking for a solution for this:

      a). Have you tried using the OverlayManager, to keep track of the currently "focused" dialog. You can then use OverlayManager's getActive method in your listeners to get a reference currently active (focused) Dialog which is to be hidden.

      b). Alternatively, you can try attaching the key listeners to the bounding box of the Dialog [ dialog.element ] as opposed to the document.

      Since you're talking modal dialogs, the Dialog which is currently the "modal" one, should be the only Dialog which has focus-able elements, and hence it's key listener will be the only one which picks up key events.

      Hope that helps,

      From: ydn-javascript@yahoogroups.com [mailto:ydn-javascript@yahoogroups.com] On Behalf Of Christian Tiberg
      Sent: Monday, June 16, 2008 6:36 AM
      To: ydn-javascript@yahoogroups.com
      Subject: [ydn-javascript] Multiple modal dialogs with KeyListener


      I solved my problem with multiple modal dialogs by a search in the group, great resource :)

      Now I'm up against the next problem. I use the following code for every dialog:

          var kl1 = new YAHOO.util.KeyListener(document, { keys:27 },                             
                                                          { fn:handleCancel,
                                                          correctScope:true }, "keyup" );
          var kl2 = new YAHOO.util.KeyListener(document, { keys:13 },                             
                                                          { fn:handleSubmit,
                                                          correctScope:true }, "keyup" );

      That's a problem when you have two forms active. Both key listeners get activated, and the *lower* form also gets dismissed. That's not what I want, but how do I prevent it? Is there some hidden variable/method in the Dialog object that can tell me whether that form is active, or will I have to manually manage a stack of forms to tell which one is on top?

      My use case is that I've got an order form, which is shown first. On that is a button to edit the package ID's that the package got when sent to the recipient, in case anything got wrong with those (sometimes the service gives you the wrong IDs). There's also another button to add multiple products to the order, which also brings up another form.

      Best regards,
      Christian Tiberg
    Your message has been successfully submitted and would be delivered to recipients shortly.