ltk常见的Lisp鼠标位置

Kot*_*pou 5 ltk common-lisp

我正在Common Lisp中制作一个简单的applet,我想使用鼠标移动来控制它。我对窗口使用LTK。我找不到任何可检索鼠标位置的函数。例如,Emacs Lisp具有(鼠标像素位置)。我在rosetta代码上找到了,但是没有Common Lisp条目。我能做什么?

Ehv*_*nce 8

这样的提示提示:鼠标位置Python Tkinter

并查看ltk的文档:http ://www.peter-herth.de/ltk/ltkdoc/node16.html

我得到以下示例来检索由鼠标移动触发的任何事件:

(ql:quickload "ltk")
(in-package :ltk-user)

(defun motion (event)
    (format t "~a~&" event))

(with-ltk ()
    (bind *tk* "<Motion>" #'motion))
Run Code Online (Sandbox Code Playgroud)

这会打开一个小窗口,里面什么也没有。一旦将鼠标放入其中,就会得到很多事件:

#S(EVENT
   :X 0
   :Y 85
   :KEYCODE ??
   :CHAR ??
   :WIDTH ??
   :HEIGHT ??
   :ROOT-X 700
   :ROOT-Y 433
   :MOUSE-BUTTON ??)
…
Run Code Online (Sandbox Code Playgroud)

#S说明我们处理的结构,命名EVENT,所以我们可以访问它的插槽(event-x event)event-mouse-button等见https://lispcookbook.github.io/cl-cookbook/data-structures.html#slot-access

另外,您可能想在freenode上加入CL社区,那里有一些游戏开发人员。