Saturday, October 5, 2013

Re: what is the shortest code to make sure a dialogbox to stay inside an area when users try to move it out of that area?

The only way the the popup is going to drag (barring the use of native dnd) is if you adjust its top and left. If you can move your popup then you should already be adjusting the top and left in your code. The popup isn't going to be aware that it's moving (keeping in mind good design) so you should be adjusting its position based on the mouse position relative to the popup and its client coordinates. So just check your mouse position relative to the popup to see if its going out of bounds in which case you stop adjusting the popup position.

On Saturday, October 5, 2013 7:41:43 PM UTC+2, Tom wrote:
Ok, let say I want my dialogbox to be moved within an area that have 500px width & 600px height. 

The rule is that If the users move the dialogbox out of that area, then the dialogbox will stay at where it was right at the point that it will be about to break the rule.

int currentTop=dialogBox.getPopupTop();
int currentLeft=dialogBox.getPopupLeft();

Ex: if the left of the dialogbox >500px & top >600px then .setPopupPosition(500, 600);
if  the left of the dialogbox >500px & top <600px & top>0 then .setPopupPosition(500, currentTop);
if  the left of the dialogbox <500px & >0 & top <600px & top>0 then .setPopupPosition(currentLeft, currentTop);
.... there are many other cases,

So what is the shortest code to make sure a dialogbox to stay inside an area when users try to move it out of that area, see an ex like this

U will see that u can't move the object out of the constrained area.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment