473,320 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Best way to implement drag and drop for a DIV?

I am implementing a "windowing" library that uses DIVs to simulate windows.

It works, but tracking of the mouse pointer is poor. In other words, as long as
I move the mouse slowly, the 'window' will track the pointer and drag
accordingly, BUT if you move the pointer quickly, it stops where it is while the
pointer goes off on its own. Oddly, it seems to be OK left and right movement,
but up and down trips it up.

I am using onmousemove/up/down etc event capture for the window DIV itself, and
tracking the cursor that way. Perhaps instead I should be capturing the
document's onmousemove/up/down events, determine if the cursor is on my window,
and move the window that way? If so, what is the best way to determine that the
object under the cursor is a window I want to move....should I set some global
status var on the DIV's onmouseover event to indicate location (title bar,
window resize handle, etc)?
Jul 20 '05 #1
2 11099
Take a look at the work done over here:

http://www.dhtmlcentral.com/

He has div based "windows", and if you look up "dhtml library" under the
Projects menu you can see the code for a drag and drop implementation.

HTH
Gabe

"Billy" <no**@none.com> wrote in message
news:mg********************************@4ax.com...
I am implementing a "windowing" library that uses DIVs to simulate windows.
It works, but tracking of the mouse pointer is poor. In other words, as long as I move the mouse slowly, the 'window' will track the pointer and drag
accordingly, BUT if you move the pointer quickly, it stops where it is while the pointer goes off on its own. Oddly, it seems to be OK left and right movement, but up and down trips it up.

I am using onmousemove/up/down etc event capture for the window DIV itself, and tracking the cursor that way. Perhaps instead I should be capturing the
document's onmousemove/up/down events, determine if the cursor is on my window, and move the window that way? If so, what is the best way to determine that the object under the cursor is a window I want to move....should I set some global status var on the DIV's onmouseover event to indicate location (title bar,
window resize handle, etc)?

Jul 20 '05 #2
Billy <no**@none.com> writes:
I am implementing a "windowing" library that uses DIVs to simulate windows.

It works, but tracking of the mouse pointer is poor. In other words,
as long as I move the mouse slowly, the 'window' will track the
pointer and drag accordingly, BUT if you move the pointer quickly,
it stops where it is while the pointer goes off on its own. Oddly,
it seems to be OK left and right movement, but up and down trips it
up.
After reading this far, my guess is that your "onmousemove" handler is
placed on the element being moved. When you move the mouse fast
enough, you move off the element, and the mousemove event no longer
reaches the element.
I am using onmousemove/up/down etc event capture for the window DIV
itself, and tracking the cursor that way. Perhaps instead I should
be capturing the document's onmousemove/up/down events,
Just the mousemove and mouseup. I think the safest is for the mousedown
to trigger "moving mode" where only mousemove and mouseup are recognized
at all, and they are handled on the document (or window) level.
the cursor is on my window, and move the window that way? If so,
what is the best way to determine that the object under the cursor
is a window I want to move


The event has a property. In standard compliant browsers, it is
"target", in IE it is "srcElement". I usually write my handlers as:

function (event) {
event = event || window.event; // IE sucks
var tgt = event.target || event.srcElement; // IE sucks
...
}

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Lauren Quantrell | last post by:
I'm trying to drop a file from Windows Explorer (or desktop, etc.) onto a field in Access2K and capture the full file path. I found an posting below that says this is possible but I cannot...
2
by: SamSpade | last post by:
There seems to be two ways to put things on the clipboard ( I don't mean different formats): SetClipboardData and OleSetClipboard If I want to get data off the clipboard do I care how it was put...
3
by: Ajay Krishnan Thampi | last post by:
I have a slight problem implementing 'drag and drop' from a datagrid to a tree-view. I have pasted my code below. Someone please advice me on what to do...pretty blur right now. ==code== ...
5
by: Ben Kim | last post by:
Hello all, Can any of you recommend some good book titles for someone that has decades of experience programming various in languages (COBOL, Basic, Clarion, etc.)? I would like a full...
0
by: Sindbaad | last post by:
Hi All, I'm using AXWEBBROWSER in my VB.Net application. I would like to implement the drag and drop event on my web page. Can I know how to proceed on this. Also the references for this. I...
3
by: VB Programmer | last post by:
In VB.NET 2005 (winform) any sample code to drag & drop items between 2 listboxes? Thanks!
1
by: pooja | last post by:
i need to implement drag and drop in treeview in VB. Kindly help. My treeview contains activities maintained using XML Files. Hopefully, Thanks.
1
by: vinaykumar Maladkar | last post by:
Hi all, i want to implement drag and drop on datagridview. I want to drag from a cell to the textbox. how can do this. thank u.
5
by: Romulo NF | last post by:
Greetings, I´m back here to show the new version of the drag & drop table columns (original script ). I´ve found some issues with the old script, specially when trying to use 2 tables with...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.