Indigo Rose Software
  #1  
Old 09-22-2005
Desmond's Avatar
Desmond Desmond is offline
Indigo Rose Staff Member
 
Join Date: Jul 2003
Posts: 628
Sample: Drag / Drop Object

This example illustrates how to use the On Mouse Move and On Mouse Button events to effectively drag and drop an object around your application.

Skills Used:
On Enter, On Leave, On Mouse Move, On Mouse Button, GetPos.
Attached Images
File Type: jpg attach1.JPG (15.4 KB, 393 views)
Attached Files
File Type: apz Drag_Drop_Object.apz (25.5 KB, 920 views)
__________________
Setup Factory 8.0 comes with over 250 actions so you can create smaller, faster and more intelligent software installers than ever before.

WebHelp Guides: AMS | MSIFACT | SUF | TU | VP
Reply With Quote
  #2  
Old 03-29-2006
pjborg's Avatar
pjborg pjborg is offline
Forum Member
 
Join Date: Feb 2001
Location: Washington State
Posts: 120
Multiple Objects

The example works great for one object, but if you want to drag and drop multiple objects those that are higher up in the z-order "steal" the cursor from those lower down. One workaround is to put the following in the page's "On Mouse Button" event:
Code:
if e_Type == 0 and sObject then
	nOrigX = e_X;
	nOrigY = e_Y;
	tProps = Button.GetProperties(sObject);
	nPos = Button.GetPos(sObject);
	bReady = true;
else
	bReady = false;
end
and put this in the page's "On Mouse Move" event:
Code:
if not System.IsKeyDown(1) then
	bReady = false;
end

if sObject and bReady then
	nChangeX = e_X - nOrigX;
	nChangeY = e_Y - nOrigY;
	Button.SetPos(tProps.ObjectName, nPos.X + nChangeX, nPos.Y + nChangeY);
end
The objects still retain their z-order, and those lower down move behind those further up, but at least you can move them around. If z-order could be changed at runtime that would work better, but I don't think that's possible. If there are better ways to drag and drop multiple objects on a page I'd love to hear about it. Thanks.
Reply With Quote
  #3  
Old 03-29-2006
Desmond's Avatar
Desmond Desmond is offline
Indigo Rose Staff Member
 
Join Date: Jul 2003
Posts: 628
Hello,

You can set Z-Order dynamically at runtime with AMS60:
http://www.indigorose.com/webhelp/am...jectZOrder.htm

Desmond.
__________________
Setup Factory 8.0 comes with over 250 actions so you can create smaller, faster and more intelligent software installers than ever before.

WebHelp Guides: AMS | MSIFACT | SUF | TU | VP
Reply With Quote
  #4  
Old 03-29-2006
pjborg's Avatar
pjborg pjborg is offline
Forum Member
 
Join Date: Feb 2001
Location: Washington State
Posts: 120
Doh

Thanks! I thought I'd looked everywhere for that. Nope!
Reply With Quote
  #5  
Old 03-29-2006
Desmond's Avatar
Desmond Desmond is offline
Indigo Rose Staff Member
 
Join Date: Jul 2003
Posts: 628
You're most welcome.
__________________
Setup Factory 8.0 comes with over 250 actions so you can create smaller, faster and more intelligent software installers than ever before.

WebHelp Guides: AMS | MSIFACT | SUF | TU | VP
Reply With Quote
  #6  
Old 04-14-2006
kelwyn kelwyn is offline
Forum Member
 
Join Date: Apr 2006
Posts: 2
Tried this

Hi I tried this template which works excellent and would be good for a test I am trying to design, but when I changed the buttons for graphics and pasted all the code into the relevant parts I kept getting an error message.

on mouse move, line 8:attempt to index global'npos'(a nil value)

Any ideas as this would really help me out, thanks.
Reply With Quote
  #7  
Old 12-15-2007
ejmlab ejmlab is offline
Forum Member
 
Join Date: Dec 2007
Posts: 1
button

I'm not sure if this will work for your purposes but if you use the button maker you can import your image, create a button and then use the code to drag and drop the new button object on the page.
Reply With Quote
  #8  
Old 01-04-2008
nitrobry's Avatar
nitrobry nitrobry is offline
Forum Member
 
Join Date: Mar 2007
Posts: 43
Hi
You can also do the same with Images

Change Button to Image



Code:
if e_Type == 0 and sObject then
	nOrigX = e_X;
	nOrigY = e_Y;
	tProps = Image[/COLOR].GetProperties(sObject);
	nPos = Image.GetPos(sObject);
	bReady = true;
else
	bReady = false;
end
And put this in the page's "On Mouse Move" event:


Code:
if not System.IsKeyDown(1) then
	bReady = false;
end

if sObject and bReady then
	nChangeX = e_X - nOrigX;
	nChangeY = e_Y - nOrigY;
	Image.SetPos(tProps.ObjectName, nPos.X + nChangeX, nPos.Y + nChangeY);
end
Reply With Quote
  #9  
Old 09-11-2009
Gelson Gelson is offline
Forum Member
 
Join Date: Sep 2009
Posts: 2
Thumbs up

Image example!
Attached Files
File Type: apz Drag_Drop_Object_Image.apz (30.0 KB, 49 views)
Reply With Quote
  #10  
Old 09-12-2009
rexzooly rexzooly is offline
Forum Enthusiast
 
Join Date: Jul 2007
Posts: 1,515
very useful thanks
Reply With Quote
  #11  
Old 2 Weeks Ago
boku's Avatar
boku boku is offline
Forum Member
 
Join Date: Mar 2009
Location: I come from a land down under Where beer does flow and men chunder
Posts: 128
Sorry for reliving this thread but I'm having difficulty running this. I want to move a window based on a hotspot having the mouse clicked in it ... but it shakes like crazy...any tips guys?
Reply With Quote
  #12  
Old 2 Weeks Ago
rexzooly rexzooly is offline
Forum Enthusiast
 
Join Date: Jul 2007
Posts: 1,515
Not seen this problem can you post a demo APZ feller and i see if it does that this end?
Reply With Quote
  #13  
Old 2 Weeks Ago
boku's Avatar
boku boku is offline
Forum Member
 
Join Date: Mar 2009
Location: I come from a land down under Where beer does flow and men chunder
Posts: 128
Hey Rex,

I learnt something instead. I didn't realise that if you disabled images they became skin as such and I could drag my form around no problems.

Thanks though
Reply With Quote
  #14  
Old 2 Weeks Ago
rexzooly rexzooly is offline
Forum Enthusiast
 
Join Date: Jul 2007
Posts: 1,515
Quote:
Originally Posted by boku View Post
Hey Rex,

I learnt something instead. I didn't realise that if you disabled images they became skin as such and I could drag my form around no problems.

Thanks though
I didn't even know what thanks for the heads up lol
Reply With Quote
Reply

Tags
drag&drop, object

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Action on Drag N Drop Jonas DK AutoPlay Media Studio 5.0 1 10-19-2008 09:55 AM
INFO: Difference between the Media Player Object and the AVI Object Support AutoPlay Media Studio 4.0 Examples 0 10-29-2002 03:15 PM
HOWTO: Make a Media Player Object Go Full Screen Support AutoPlay Media Studio 4.0 Examples 0 10-23-2002 12:23 PM
INFO: Minimum requirements for the Flash Object, Media Player Object, and Web Browser Object Support AutoPlay Media Studio 4.0 Examples 0 10-04-2002 11:09 AM


All times are GMT -6. The time now is 04:53 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software