473,405 Members | 2,373 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,405 software developers and data experts.

How to drag images with a mouse?

Hi, everybody!

I want to implement in JScript an image-dragging functionality like the one
in image processing apps like Adobe Photoshop etc., when:

a) I press a left button when a cursor is over the image (say, x0,y0).
b) Holding a button, I start dragging. An image 'sticks' to a cursor and
moves with it.
c) When I release a button, an image has to reside in (x1,y1) until I want
to drag it again.

At this time I KNOW how:
a) To intercept a mouse-click (measuring X and Y and storing in a function
called by onkeyup event)
b) How to draw an image :-)
[Seriously, (b) may matter, since image may be drawn either as itself,
or as a background of some element, which may be dragged.]

What I don't know, is:
a) what HTML elements may be dragged, and what may not; and what methods
should be used.

- So, would anybody be so kind to provide a relevant link, or a code sample,
or... maybe it's impossible to do it at all - sorry, I'm a novice in JScript
programming...

Thanks in advance.

--
A.D.
Feb 12 '07 #1
2 4040
Abraham Durceau wrote:
Hi, everybody!

I want to implement in JScript an image-dragging functionality like the one
in image processing apps like Adobe Photoshop etc., when:

a) I press a left button when a cursor is over the image (say, x0,y0).
b) Holding a button, I start dragging. An image 'sticks' to a cursor and
moves with it.
c) When I release a button, an image has to reside in (x1,y1) until I want
to drag it again.

At this time I KNOW how:
a) To intercept a mouse-click (measuring X and Y and storing in a function
called by onkeyup event)
b) How to draw an image :-)
[Seriously, (b) may matter, since image may be drawn either as itself,
or as a background of some element, which may be dragged.]

What I don't know, is:
a) what HTML elements may be dragged, and what may not; and what methods
should be used.

- So, would anybody be so kind to provide a relevant link, or a code sample,
or... maybe it's impossible to do it at all - sorry, I'm a novice in JScript
programming...

Thanks in advance.

--
A.D.


This links to one of the articles I wrote so it's a self-prmoting link.
It does however does provide a solid framework that you can use to
expand on. The initial demonstration is for a video layer but if you
scroll down to the bottom there's a link to full source code for a
moveable image as well.

http://www.hunlock.com/blogs/Javascript_Drag_and_Drop

--
http://www.hunlock.com -- Musings in Javascript, CSS.
$FA
Feb 12 '07 #2

On Feb 11, 4:19 pm, "Abraham Durceau" <abrahamdurc...@post.ruwrote:
a) what HTML elements may be dragged, and what may not; and what methods
should be used.
Anything that can be absolutely positioned can be dragged.

On Feb 11, 4:19 pm, "Abraham Durceau" <abrahamdurc...@post.ruwrote:
- So, would anybody be so kind to provide a relevant link, or a code sample,
or... maybe it's impossible to do it at all
I'm partial to http://developer.yahoo.com/yui/dragdrop/
Lots of examples, and pretty easy to set up.

--
Isaac Z. Schlueter
http://isaacschlueter.com

Feb 28 '07 #3

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

Similar topics

9
by: Stuart Wexler | last post by:
Hi, I want to set up a JS/DHTML page that allows someone to graphically/manually rank items. For instance, they would have 10 movies, and they can move things around, 1 to 10, according to...
1
by: portraitmaker | last post by:
I found some drag and drop code on the web and modified it a little b taking out some of the stuff I didn't need. This sample allows you to drag an image in a table to another positio and swaps...
3
by: Fred R | last post by:
I'm designing an app in Access 97 that will facilitate the uploading of records and images to a website. The user selects the image thumbnails from the file system and drags them into the app....
0
by: Art Decco | last post by:
For some reason I was under the impression that .Net's RichTextBox supported drag and drop editing, but if it does, I don't see how to turn it on. I'm not talking about dragging files or images...
1
by: Curtis Justus | last post by:
Hi, My goal is to have a series of thumbnail images on a control/panel and to drag/drop those items onto another control (i.e. a treeview). I am able to drag one item and need to somehow select...
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== ...
2
by: sebastian.janoschka | last post by:
Hi, I build my first Drag & Drop with JavaScript and I would like to drag the pictures when I click on it. When I create a normal div tag with some text the script works, but when I put a...
7
by: Peter Pearson | last post by:
Tkinter makes it very easy to drag jpeg images around on a canvas, but I would like to have a "target" change color when the cursor dragging an image passes over it. I seem to be blocked by the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.