如何在运行时移动由鼠标控制的TPanel?
我想在运行时使用 Delphi 10.4.2 和 FMX 通过鼠标将 TPanel
移动到另一个 TPanel
上。我尝试了 OnMouseDown
、OnMouseMove
和 OnMouseUp
事件。但尚不清楚事件中X
和Y
值的内容是什么。文档说它们是屏幕坐标。相对于屏幕、窗体、父控件还是控件本身?如何解决TPanel
的移动问题?
I want to move a TPanel
on another TPanel
by mouse at runtime with Delphi 10.4.2 and FMX. I tried OnMouseDown
, OnMouseMove
and OnMouseUp
events. But it is not clear what the contents of X
and Y
values are in the events. The documentation says that they are screen coordinates. Relative to the screen, form, parent control or the control itself? How can I solve the movement of the TPanel
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,事实并非如此。 FMX.Types.TMouseEvent 和 FMX.Types.TMouseMoveEvent
文档都说:
像这样:
基本上,当鼠标在面板上移动时,代码只是计算鼠标从最后一个已知位置移动到当前位置的偏移量,然后将该偏移量应用到面板的当前位置 code> 在其
Parent
中。No, it doesn't. The FMX.Types.TMouseEvent and FMX.Types.TMouseMoveEvent
documentation both say:
Like this:
Basically, while the mouse is moving around the Panel, the code is simply calculating the offset the mouse has moved from the last known position to the current position, and then applying that offset to the Panel's current
Position
within itsParent
.