为什么我不能在构造函数中捕获鼠标
我有来自形状的自定义形状。在构造函数内部我想捕获鼠标,我不能,我只能在创建形状后捕获它,有谁知道为什么,我想在构造函数内部捕获它?
I have custom shape deriving from shape. Inside the constructor I want to capture the mouse, I cannot, I can only capture it once the shape has been created, does any one know why, I would like to capture it inside the constructor?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您需要根据鼠标光标的位置或移动创建不同的形状,我将使用您的窗口或父容器的适当事件来收集此信息(例如“捕获”您的鼠标)并将此信息直接传递给构造函数或者根据此信息调用某个子类的适当构造函数。
则无需在构造函数中捕获此信息。
If you need to create different Shapes depending upon the position or movement of the mouse cursor I would use the appropriate events of your Window or parent container to gather this information (e.g. to "capture" your mouse) and pass this information directly to the constructor or call an appropriate constructor of a certain subclass depending upon this information.
There is no need to capture this info in constructor then.