Re: Disabling toolbar buttons
"Krupka Michal (as michal dot krupka at upol dot cz)" <[email protected]>
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <[email protected]> |
Hi Alexey, This works, thanks. I have two comments. Using accessor capi:simple-pane-enabled for toolbar-button is mentioned here: https://www.lispworks.com/documentation/lw81/capi-w/capi-capi-ref-509.htm#CAPI)toolbar-object So, it is probably a bug in LWW that it doesn't work on Windows. And second, the function capi:interface-update-toolbar is not documented. Is it safe to use? Michal > 30. 9. 2025 v 0:01, Alexey Veretennikov <[email protected]>: > > 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