Re: Disabling toolbar buttons
"Alexey Veretennikov (as alexey dot veretennikov at protonmail dot com)" <[email protected]>
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <PPN-AQvZ-eUTJLyVHGyYVrSiQGkuJpAQdk3kNtI1UJT0iE74vyF3GtCQeMSGEu0YWY-oxsmQkJIH87v3wXEMTygq9goxzEK_FzUzpQUPsf0=@protonmail.com> |
Hi,
Proper way to do it is to define :enabled-function on a toolbar button and force CAPI to update the state by calling capi:interface-update-toolbar.
Works for both Windows and Linux (don't have OSX around to test).
(capi:define-interface minimal-interface ()
((toolbar-button-enabled-p :initform t))
(:panes (btn capi:push-button
:text "enable/disable"
:callback
(lambda (intf)
(with-slots (toolbar-button-enabled-p) intf
(setf toolbar-button-enabled-p
(not toolbar-button-enabled-p)))
(capi:interface-update-toolbar intf))
:callback-type :interface))
(:default-initargs
:toolbar-items
(list
(make-instance 'capi:toolbar-button
:enabled-function
(lambda (intf)
(slot-value intf 'toolbar-button-enabled-p))
:image :std-copy))))
BR,
/Alexey
On Monday, September 29th, 2025 at 14:29, Krupka Michal (as michal dot krupka at upol dot cz) <[email protected]> wrote:
> According to the CAPI doc, enabling/disabling of toolbar buttons can be done through capi:simple-pane-enabled. This works for me in Mac OS but in Windows it does nothing. Here is an example:
>
> (capi:define-interface minimal-interface ()
> ()
> (:panes (btn capi:push-button
> :text "enable/disable"
> :callback (let ((enabled nil))
> (lambda (intf)
> (setf (capi:simple-pane-enabled
> (first (capi:interface-toolbar-items intf)))
> (setf enabled (not enabled)))))
> :callback-type :interface))
> (:default-initargs
> :toolbar-items
> (list
> (make-instance 'capi:toolbar-button
> :image :std-copy))))
>
> (capi:display (make-instance 'minimal-interface :width 50 :height 50))
>
> Clicking the push button should enable/disable the toolbar button, but in Windows it doesn't work. Any ideas?
>
> (In Mac OS the toolbar button isn't visible, but it doesn't matter as the question is about Windows)
>
> Michal
>
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> [email protected]
> http://www.lispworks.com/support/lisp-hug.html
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
[email protected]
http://www.lispworks.com/support/lisp-hug.html