Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 7:21 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: Simple. Drag & Drop, and Draw
PostPosted: November 17th, 2007, 1:02 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Simple but am stuck. Is in Advanced section, since uses Scripts for drawing.

in the example a user drags an object, Opus Draws a line from starting point to place where user Drops an object. Great, that works. Can change to different drop zone.

Need help for condition when User drags object out of valid Drop Zone. Want the line to disappear when object returns to its 'home'.

Thanks.
p.s. I will have 12 objects to drag... so looking for streamlining coding.


You do not have the required permissions to view the files attached to this post.

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: November 17th, 2007, 2:22 pm 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 512
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
a very simple way is to add a left mouse trigger which clears the drawing frame before the drop trigger.
When you click on the object, any previous line is cleared first, if it's a valid drop the line is re-drawn. If it's not a valid drop, the line isn't re-drawn.


Sandy

_________________
Whoever designed this, never actually used it!


Top
 Profile  
 
 Post subject:
PostPosted: November 18th, 2007, 8:04 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
I think you mean add that trigger to the Dragged object. I'll try that. Previously I had trouble putting a xx.ClearDraw() action that could get called before a real Draw action.

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: November 18th, 2007, 11:02 am 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 512
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
Yes :-). Sorry I wasn't clearer. I tried it and it works fine, but there is probably several other ways of doing it.

A screen refresh can be forced by using a wait(0) this may be required between the ClearDraw and Draw statements
Sandy

_________________
Whoever designed this, never actually used it!


Top
 Profile  
 
 Post subject:
PostPosted: November 19th, 2007, 11:53 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Putting a ClearDraw() under a mouseclick trigger prevented any lines from being drawn as part of the Drop action. So that does not appear to be a solution.

BTW, I did not use a 'wait' in the example .imp... and lines did erase and redraw correctly as long as another valid drop was achieved.


Here's the script used with 'This Object Dropped' trigger under Button_1. Works well to move line when Button moved to different drop zone. Fails to remove line when "not dropped".
Code:
frame1.ClearDraw();
var ToPos = Button_1.GetPosition();
var FromPos =  Vector_1.GetPosition()
frame1.DrawLine( FromPos, ToPos );


Quote:
but there is probably several other ways of doing it.


Open to other suggestions.

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: November 19th, 2007, 12:14 pm 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 512
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
I have two triggers attached to the draggable object.
first:- "This object dropped all objects"

Code:
dframe1.SetLineColour("red");
var FromPos =  Vector_27.GetPosition()
var ToPos = Vector_28.GetPosition();
wait()
dframe1.DrawLine( FromPos, ToPos );


Add the "wait(0)"

then:-"Left Mouse Click"
with a script attached and

Code:
dframe1.ClearDraw();


Works perfect---I can drag and drop the object and the line is drawn.

If I move the object off the target, the line is cleared. If I drag it to another valid drop the line is drawn, if I drag it to another drop zone the first line clears and the new line is drawn.


Sandy

_________________
Whoever designed this, never actually used it!


Top
 Profile  
 
 Post subject:
PostPosted: November 19th, 2007, 5:35 pm 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 512
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
the modified IMP
I have modified the actions of both stars to work correctly...I hope :-)


You do not have the required permissions to view the files attached to this post.

_________________
Whoever designed this, never actually used it!


Top
 Profile  
 
 Post subject: Cool, simple draw connector lines. Works!
PostPosted: November 19th, 2007, 10:28 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Sandyn, thanks... wait(), applause! :lol: :lol:

Works perfect.
Now if I could just understand 'why' that little wait command makes all the difference?

I guess impatience is highly overrated.

thanks.

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: November 19th, 2007, 10:35 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
...because certain events happen faster than others such as a screen update. The wait simply gives these events the chance to 'catch up'

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 20th, 2007, 12:21 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
thanks, Mac.

So in this case, are we waiting for the ClearDraw from the MouseClick before going on to the DrawLine under the drop trigger?

I ask, as there's not much 'code' going on above the wait() command. Also, I tried putting a wait() under the MClk action (after the ClearDraw there)... and that did not work.

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: November 20th, 2007, 1:38 am 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 512
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
I think there's an element of serendipity with my design :-)
When you click on the drag-able object, it triggers a ClearDraw(), but it seems the screen isn't updated until the wait(0). See the help on "wait()"


from help file:-
Quote:

Example 2: Refreshing the screen

The wait function can be set to zero, which is often used to update the screen. For example, if you do this

for(..;..;..)
{
Image_1.Show()
Image_1.Hide()
}

You may expect the image to flicker, however, the screen is not updated between the Show and Hide. To update the screen, use wait(0):

for(..;..;..)
{
Image_1.Show()
Wait(0)
Image_1.Hide()
}


there is a problem with my method :-( if you have dragged the star to the square--it's OK. If you move the star within the square---it's OK, but if you click on the star in the square, but not move it, the line is cleared.
this can be overcome by doing the following
add the following to the script in the mouse click trigger after the ClearDraw()



Code:
if(Vector_28.IsObjectIntersecting(Vector_29))
{
   wait(0)
   dframe1.DrawLine( FromPos, ToPos );
}




(Vector_28 is the star and Vector_29 is the rectangle)

You also need to 'OR' this with the other vectors in the IF statement so that this method can be expanded to work when the red star is dragged to any rectangle. I haven't tried the 'OR' bit, but I think it should work???
If you have problems, I'll post an IMP tomorrow---it's past my bedtime.
PS I could have used:
if(this.IsObjectIntersecting(Vector_29))

Sandy

_________________
Whoever designed this, never actually used it!


Top
 Profile  
 
 Post subject:
PostPosted: November 20th, 2007, 8:28 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Sandy,

Thanks for further refining. Should prove useful to others here too.

Quote:
there is a problem....if you have dragged the star to the square-- but if you click on the star in the square, but not move it, the line is cleared.


Very true.



Quote:
You also need to 'OR' this with the other vectors... so that this method can be expanded to work when the red star is dragged to any rectangle. I haven't tried the 'OR' bit, but I think it should work???


I might try something with a test for "dropped" as a property of the Star object. Otherwise I am concerned with the IF statement and coding all the combinations of drag-objs and dropzones. One page I plan will have 8 draggable onto 5 dropzones. Also will look to move some code to 'functions' if that makes sense.

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: November 20th, 2007, 8:33 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Oh, on the 'wait' thing. I didn't expect screen refresh was entering here. As you saw, having ClearDraw and then DrawLine in one script was operating well (except for the object returning condition).

I guess because a separate trigger event was used, this action of drop and draw needed the time (wait).

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 50 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group