我正在AMD64机器上使用SBCL for Linux。
功能ANIMTEST使用CANVAS小部件实例化LTK窗口。两件物品BARRIER和FOLLOWER住在画布上。两者都连续旋转,BARRIER位于画布的中心,FOLLOWER意图跟随鼠标,该鼠标不按预期工作。我的第一次尝试(见注释)导致鼠标的绝对屏幕坐标被解释为画布内的相对坐标,而不考虑两者之间的偏移。在搜索完ltk.lisp和文档后,我找到了SCREEN-MOUSE-X/Y(第二次尝试,请参阅评论)。我觉得我根据文档使用SCREEN-MOUSE-X & -Y,但它为什么不起作用? = Note = 包含ANIMTEST的文件及支持它的包加载并运行时没有错误。 我定义的函数(UCTK-BEAM等)已经过测试并运行良好。无法访问与CANVAS小部件相关的鼠标坐标
(defun animtest()
"Test a spinning figure in LTK"
(with-ltk()
(let* ((cnvs (make-instance 'canvas :width 400 :height 400))
(barrier (uctk-beam 200 200 40 20))
(follower (uctk-beam 0 40 40 20))
(slp-time 50) ; in ms
(bar-theta 0)
(fol-theta 0))
(labels ((update()
(draw barrier nil)
(draw follower nil)
(incf bar-theta (/ pi 15))
(incf fol-theta (/ pi 15))
(geo:set-theta barrier bar-theta)
(geo:set-theta follower fol-theta)
(geo:set-center follower
;== FIRST ATTEMPT ==
(cons (screen-mouse-x cnvs)
(screen-mouse-y cnvs)))
; == SECOND ATTEMPT ==
;(cons (canvasx cnvs (screen-mouse-x cnvs))
; (canvasy cnvs (screen-mouse-y cnvs))))
(after slp-time #'update)))
(pack cnvs :fill :both :expand 1)
(update)))))
提前感谢!