• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

onMouseUp in Safari

 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have been trying to implement drag and drop in a Web interface, using
JavaScript. I have written my own, rather than use a library, because
the drag and drop has to play nicely with a table row
multiple-selection library that I also wrote.

I care about Internet Explorer 6+, FireFox 2+ and Safari 2+. It works
fine on the first two, but not on Safari.

The problem seems to be that Safari fires the onMouseUp event on the
element that was under the mouse when the mouse button went down. In
drag and drop, one has typically moved the mouse to a different element
(the drop target) by the time the mouse button comes up. On the other
browsers, the event fires on that element.

Is there any way to find out what element was under the mouse when the
button came up? I have tried the relatedTarget, currentTarget and
target attributes of the event, but so far not found what I want.

If not, any suggestions on how to make this work on Safari?

I notice Safari has its own non-standard (but IE-like?) events for drag
and drop. However, I don't really want to use those because (a) they
are non-standard so different code would be needed for different
browsers, (b) it probably wouldn't play nicely with my
multiple-selection library.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am guessing you found this page on your journey:
http://developer.apple.com/documentation/AppleApplications/Reference/SafariJSRef/Classes/Events.html

In most drag and drops, the element you clicked on is stuck to mouse so the onmouseup would be that element. (Want to have fun, drag the item to the edge of the page so your mouse is not on the browser. When you are off the browser release the mouse button and go back onto the page.

Eric
 
Peter Chase
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my drag and drop, I don't drag the originally-clicked element, because that would look silly (can't illustrate with pictures, so take my word for it). Instead, I drag a little document icon. I position this just to the right of the mouse pointer, so the mouse isn't over it.

On IE and FireFox, this works very nicely. The little icon gets dragged and an onMouseUp event fires from the place where I let go. On stupid Safari - a browser on a one-man mission to make even IE look good - it fires from the place I first clicked.

That wouldn't matter if there was any way to find out where you let go, but there isn't. Well, actually it might be possible to work it out, by comparing mouse position with element positions. That's a last resort, though, because anything to do with absolute positions is so horribly broken in DHTML.

Any other suggestions?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic