Views and subviews
(add-subviews (target)
(make-instance 'button-dialog-item
:dialog-item-text "Beep"
:dialog-item-action
#'(lambda (self)
(declare (ignore self))
(beep))))
In this case, the action is an anonymous function. That's the meaning of the expression beginning with "#'(lambda...". The lambda expression creates a function of one argument, self, it ignores that argument, and it then calls the function beep. The anonymous function is stored as the action-function of the dialog item. It is called when the button is clicked.
When a button's action-function is called, the button itself is passed as an argument. That way the function can find out what dialog it is in, etc. In this case, we do not need to use that information. That's why we declare that we are ignoring the argument. If the lambda expression did not include that declaration, the compiler would issue a warning about an unused argument.
Generated with Harlequin WebMaker