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

  • Home
  • SEARCH
  • 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 786047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:58:34+00:00 2026-05-14T20:58:34+00:00

I am trying to implement drag and drop between two listboxes. I have a

  • 0

I am trying to implement drag and drop between two listboxes.

I have a few problems

1) I am not detecting any drag events of any kind from the source list
box/ I do not seem to be able to drag from it

2) I can drag from my desktop to the target listbox and I am able to
detect ‘dragenter’ ‘dragover’ and ‘dragexit’ events. I am noticing
that the event parameter is undefined in my ‘dragenter’ callback – is
this a problem?

3) I cannot figure out how to complete the drag and drop operation.
From https://developer.mozilla.org/En/DragDrop/Drag_Operations#Performing_…
“If the mouse was released over an element that is a valid drop
target, that is, one that cancelled the last dragenter or dragover
event, then the drop will be successful, and a drop event will fire at
the target. Otherwise, the drag operation is cancelled and no drop
event is fired.”

This seems to be referring to a ‘drop’ event, though there is not one
listed at https://developer.mozilla.org/en/XUL/Events . I can’t seem
to detect the end of the drag in order to call one of the example
‘doDrop()’ functions that I find on MDC.


My example, so far: http://pastebin.mozilla.org/713676

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/
there.is.only.xul"
onload="initialize();">
   <vbox>
       <hbox>
           <vbox>
               <description>List1</description>
               <listbox id="source" draggable="true">
                   <listitem label="1"/>
                   <listitem label="3"/>
                   <listitem label="4"/>
                   <listitem label="5"/>

               </listbox>
           </vbox>
           <vbox>
               <description>List2</description>
               <listbox id="target" ondragenter="onDragEnter();">
                   <listitem label="2"/>
               </listbox>
           </vbox>
       </hbox>
   </vbox>
<script type="application/x-javascript">
<![CDATA[
   function initialize(){
       jsdump('adding events');
       var origin = document.getElementById("source");
       origin.addEventListener("drag", onDrag, false);
       origin.addEventListener("dragdrop", onDragDrop, false);
       origin.addEventListener("dragend", onDragEnd, false);
       origin.addEventListener("dragstart", onDragStart, false);

       var target = document.getElementById("target");
       target.addEventListener("dragenter", onDragEnter, false);
       target.addEventListener("dragover", onDragOver, false);
       target.addEventListener("dragexit", onDragExit, false);
       target.addEventListener("drop", onDrop, false);
       target.addEventListener("drag", onDrag, false);
       target.addEventListener("dragdrop", onDragDrop, false);

   }

   function onDrag(){
       jsdump('onDrag');
   }

   function onDragDrop(){
       jsdump('onDragDrop');
   }

   function onDragStart(){
       jsdump('onDragStart');
   }

   function onDragEnd(){
       jsdump('onDragEnd');
   }

   function onDragEnter(event){
       //debugger;
       if(event){
           jsdump('onDragEnter event.preventDefault()');
           event.preventDefault();
       }else{
           jsdump("event undefined in onDragEnter");
       }

   }

   function onDragExit(){
      jsdump('onDragExit');
   }

   function onDragOver(event){
       //debugger;
       if(event){
           //jsdump('onDragOver event.preventDefault()');
           event.preventDefault();
       }else{
           jsdump("event undefined in onDragOver");
       }

   }

   function onDrop(event){
         jsdump('onDrop');
         var data = event.dataTransfer.getData("text/plain");
         event.target.textContent = data;
         event.preventDefault();
   }

function jsdump(str)
{
 Components.classes['...@mozilla.org/consoleservice;1']
           .getService(Components.interfaces.nsIConsoleService)
           .logStringMessage(str);

}

]]>
</script>
</window> 
  • 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-05-14T20:58:35+00:00Added an answer on May 14, 2026 at 8:58 pm

    I was using xulrunner 1.9.0 as opposed to 1.9.1 when these features were introduced.

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

Sidebar

Ask A Question

Stats

  • Questions 382k
  • Answers 382k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I would suggest that you use the Oracle provided ODP.NET.… May 14, 2026 at 10:29 pm
  • Editorial Team
    Editorial Team added an answer I'm sure there's some ready made magical array functions that… May 14, 2026 at 10:29 pm
  • Editorial Team
    Editorial Team added an answer target instruction, represented as a 1-byte signed offset from the… May 14, 2026 at 10:29 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.