Question

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!

Was it helpful?

Solution

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)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top