禁用 lispworks capi:push-button-panel 上的单个按钮
我正在使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
稍微搜索一下手册就会发现这个函数,它允许您启用/禁用
按钮面板
中的一个或多个元素。此外,您想要解释的代码使用参数nil
和my-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 argumentsnil
andmy-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)