限制只绘制一个矩形 [英] Limit the drawing of only One rectangle

查看:66
本文介绍了限制只绘制一个矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在尝试使用鼠标点击绘制一个矩形并通过单击边框移动/缩放。



如何限制使用鼠标只绘制一个矩形点击而不是在我移动或缩放时绘制的许多矩形。



我创建了一个变量oneRect并将其设置为true,在绘制矩形后我将其设置为false并每次检查变量的值。

小提琴是:



http://jsfiddle.net/URWru/93/



请告诉我出错的地方。

Hi I am trying to draw a rectangle using mouse clicks and move/scale by clicking the border.

How can I limit to draw only one rectangle using mouse clicks instead of many rectangles which are drawn when I m moving or scaling it.

I created a variable oneRect and set it to true and after the rectangle is drawn I set it to false and checked the variable's value each time.
fiddle is :

http://jsfiddle.net/URWru/93/

Please let me know where I am going wrong.

推荐答案

除了鼠标位置和矩形之间的几何变化外,我没有看错。



似乎你不需要限制任何东西。相反,你应该用更好的东西替换矩形按钮。此按钮看起来像激活矩形模式。只有,按钮不好,因为它没有提供视觉线索。您需要一组具有独家选择的按钮。一组单选按钮可以完美地工作,但你可以给它提供更多信息(例如,图像显示什么是活动操作)。然后,当选择此工具选择元素时,您可以根据用户的需要多次使用此工具。我从来没有见过比这更好的东西。



-SA
I see nothing wrong, except some shift in geometry between mouse position and the rectangle.

It does not seem that you need to limit anything. Instead, you should replaced "rectangle" button with something better. This button looks like activation of "rectangle mode". Only, button is not good, because it does not deliver a visual clue. You need to have a set of buttons with exclusive selection. A set of radio button would work perfectly, but you can just give it more informative appearance (say, image showing what is the active operation). Then, when this tool selection element is selected, you use this tool as many times as the user wants. I never saw anything much better than that.

—SA


这篇关于限制只绘制一个矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆