禁用 lispworks capi:push-button-panel 上的单个按钮

发布于 2024-11-15 03:42:27 字数 673 浏览 10 评论 0原文

我正在使用 Common Lisp 和 LispWorks CAPI 开发四子棋游戏。我已经完成了界面,除了一件事:我使用按钮(在按钮面板中)将片段放入列中,并且我想在相应的列已满后禁用按钮。我对lisp比较陌生,尤其不了解面向对象的东西,所以我不知道该怎么做。

可以这样创建单个按钮:

(setf my-button (capi:contain
                 (make-instance 'capi:push-button
                                :text "Button!")))

并因此禁用:

(capi:apply-in-pane-process 
 my-button #'(setf capi:button-enabled) nil my-button)

按钮面板的创建方式类似,不同之处在于它采用 :items 参数,该参数是按钮列表(或数据,其中CAPI 将在面板中创建按钮。

我只需要知道如何禁用按钮面板的各个按钮。如果您能解释最后一段代码中发生的情况,那就太好了,因为我根本不明白它。

谢谢!

I'm working on a Connect Four game using common lisp and the LispWorks CAPI. I'm finished with the interface except for one thing: I use push-buttons (in a push-button-panel) to drop pieces into the columns, and I'd like to disable a button once its corresponding column is full. I'm relatively new to lisp, and I especially don't understand the object-oriented stuff, so I can't figure out how to do it.

A single push-button can be created thisly:

(setf my-button (capi:contain
                 (make-instance 'capi:push-button
                                :text "Button!")))

And disabled thusly:

(capi:apply-in-pane-process 
 my-button #'(setf capi:button-enabled) nil my-button)

A push-button-panel is created similarly, except it takes an :items argument that is a list of buttons (or data, which the CAPI will create buttons out of) to be in the panel.

I simply need to know how to disable the individual buttons of a push-button-panel. Also it would be nice if you could explain what is happening in that last piece of code there, because I don't understand it at all.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光礼记 2024-11-22 03:42:27

稍微搜索一下手册就会发现这个函数,它允许您启用/禁用按钮面板中的一个或多个元素。此外,您想要解释的代码使用参数 nilmy-button 调用函数 (setf capi:button-enabled)。但是,此函数是在与您的按钮关联的“进程”中调用的。 (请参阅文档此处

(PS如果您需要帮助理解“面向对象的东西”,实用通用Lisp 可能是一个有用的资源)

A bit of searching through the manual reveals this function, which allows you to enable/disable one or more elements in a push-button-panel. Also, the code you wanted explained calls the function (setf capi:button-enabled) with the arguments nil and my-button. However, this function is called in the "process" associated with your button. (see the documentation here

(P.S. If you need help understanding the "object oriented stuff", Practical Common Lisp might be a useful resource)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文