If you use the above condition object inside/outside an area, you need another way to find out if user drag object into/out of that area.

Some more code need to be added to my previous replied message:

if(ox+w/2>oxmax)ox=oxmax-w/2;
if(out){
if(ox-w/2<oxmin && oy+h/2>oymin)oy=oymin;
if(ox-w/2>=oxmin && ox+w/2<=oxmax && oy+h/2>oymin)out=false;// move into hot area
}else{
if(ox-w/2<oxmin)ox=oxmin+w/2;
if(ox+w/2>oxmax)ox=oxmax-w/2;
if(oy+h/2>oymax)oy=oymax-h/2;
[b]if(ox-w/2>=oxmin && ox+w/2<=oxmax && oy-h/2>oymin)out=true; // move out of hot area[/b]
}