Page 1 of 2
trash bin like feature
Posted: Wed Mar 06, 2013 8:16 pm
by demolken
I've been trying to implement a recycle bin like feature. I've been trying to do this by detecting if there are images within a field however, i cant seem to work out the problems.
Re: trash bin like feature
Posted: Wed Mar 06, 2013 9:02 pm
by Klaus
Hi demolken,
I don't have the slightest idea what you are talking about resp. what you are trying to achieve!?
Best
Klaus
Re: trash bin like feature
Posted: Wed Mar 06, 2013 11:30 pm
by mwieder
Klaus- not to worry. I think it's just another spam message.
Re: trash bin like feature
Posted: Thu Mar 07, 2013 2:40 am
by dunbarx
This seems like a reasonable request, and a reasonable approach to finding a solution, detecting whether one object is within the rect of another.
Only a single post, but why think it is bogus? If spam, it is very well done in a LC context. We need the algorithms that produced it.
So Demolken, are you for real?
Craig Newman
Re: trash bin like feature
Posted: Fri Mar 08, 2013 8:25 pm
by demolken
yes i'm real. Sorry for the difficult explanation but craig seems to have answered my question. Thank you
Re: trash bin like feature
Posted: Fri Mar 08, 2013 9:20 pm
by Klaus
Hi Demolken,
AHA!
OK, welcome to the forum!
Best
Klaus
Re: trash bin like feature
Posted: Fri Mar 08, 2013 9:23 pm
by mwieder
Yay! on all counts.

Re: trash bin like feature
Posted: Fri Mar 08, 2013 9:38 pm
by dunbarx
Goodie.
And Demolken, since you appear to be well on your way with the "within" function, which pertains to objects, do also look at the "is within" operator, which is similar, but pertains to points.
If you intend to animate your trashcan gizmo, please demonstrate it here.
Craig Newman
Re: trash bin like feature
Posted: Fri Mar 08, 2013 10:17 pm
by dunbarx
I was thinking about this, and thought I was presumptuous
I made two buttons. In the script of the first one (the button to be trashed) I put:
Code: Select all
on mouseMove
if the mouse is down then set the loc of me to the mouseLoc
end mouseMove
on mouseup
if the loc of me is within the rect of btn "trashCan" then put random(99)
end mouseup
This uses the "is within" operator as opposed to the "within" function that I assumed earlier. You may be well ahead of this already.
Craig Newman
Re: trash bin like feature
Posted: Sat Mar 09, 2013 11:28 am
by Klaus
Hi friends,
watch out!
Code: Select all
on mouseMove
if the mouse is down then set the loc of me to the mouseLoc
end mouseMove
"Polling" the mouse in this way is SIN and will lead to eternal damnation:
http://www.hyperactivesw.com/resources_polling.html
Best do this instead "on mousemove":
Code: Select all
on mousedown
grab me
end mousedown
Best
Klaus
Re: trash bin like feature
Posted: Sat Mar 09, 2013 6:11 pm
by dunbarx
Klaus.
Yep, grab is better. More relaxing to the engine.
But polling, when an action is wholly dedicated to a particular task, does not seem to me to be so dastardly. Certainly if any other task at all might be running at the same time, or might be called or invoked during that action, then a "send in time" or somesuch is proper.
Still does not mean that "grab" is not better.
Craig
Re: trash bin like feature
Posted: Sat Mar 09, 2013 7:42 pm
by jacque
dunbarx wrote:
But polling, when an action is wholly dedicated to a particular task, does not seem to me to be so dastardly. Certainly if any other task at all might be running at the same time, or might be called or invoked during that action, then a "send in time" or somesuch is proper.
If it only involved LiveCode itself then you're right. The problem is, though, that it stops the whole computer. All background tasks in all open apps, including the OS, are suspended or at least greatly slowed down. Dr Raney's pet peeve with this (he was the original damnation-caster) was that every other app came to a halt while the tight polling loop used almost 100% of the CPU.
Re: trash bin like feature
Posted: Sat Mar 09, 2013 9:58 pm
by dunbarx
Jacque.
I watched the "Activity Monitor" while this was running:
Code: Select all
on mouseMove
if the mouse is down then set the loc of me to the mouseLoc
end mouseMove
I could be completely misreading this application, but whereas when nothing was going on in LC, CPU usage was about 17%. During the actual mouseMove action, activity dropped to about 10%, and sometimes lower. In other words, to free up the CPU, run a CPU intensive process.
About the same response using "grab", by the way.
Macbook Air, 1.86 GHz.
Craig
Re: trash bin like feature
Posted: Sat Mar 09, 2013 10:11 pm
by sturgis
Based on the linked page, checking things in the mousemove is the "recommended" method. The linked page rather says the following is bad.
Code: Select all
repeat until the mouse is up
set the loc of btn "dragBtn" to the mouseLoc
end repeat
This isn't polling, its just a message being handled and should work great.
Code: Select all
on mouseMove
if the mouse is down then set the loc of me to the mouseLoc
end mouseMove
Re: trash bin like feature
Posted: Sun Mar 10, 2013 5:45 pm
by Newbie4
Does it matter if you use the "intersect" function, "is within" or the "within" function for testing if the object is in the trashcan?