Capi Linux enabled-function issue
"WeebWolf (as jarek dot kligl7 at gmail dot com)" <[email protected]>
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <CAN-tqzRc0ctdQ=hhPc+kucpOrWAEtOyNq-1nzwO3Uq30XpmLsg@mail.gmail.com> |
On Linux (X11), if you use :enabled-function in a menu-item, the item's enabled state doesn't update correctly. It only calls the enabled function when the menu is clicked. For example, if you have an accelerator, it can still call the menu function even when it should be disabled. On Windows, this works perfectly fine. Neither redisplay-menu-bar nor redisplay-interface work. It also doesn’t call enable-function when the interface is created, treating every menu item as enabled by default. In the example, on linux shortcuts work unless you already clicked on the menu, and in Windows everything works as expected. Has anyone encountered this before? JK
example.lisp
(text/x-common-lisp, 1.4 KB)
(capi:define-interface example () ()
(:menus
(file-menu "info-msg" nil :items-function 'example-menu))
(:menu-bar file-menu)
(:panes
(pane-1 capi:text-input-pane
:reader pane1)
(pane-2 capi:text-input-pane
:reader pane2)
(switch capi:check-button
:text "Enable Shortcuts"
:reader switch))
(:default-initargs
:auto-menus nil))
(defmethod shortcuts-p ((initf example))
(capi:button-selected (switch initf)))
(defun example-menu (interface)
(declare (ignore interface))
(list (make-instance 'capi:menu-item
:title "display first text"
:callback 'first-text-msg
:callback-type :interface
:enabled-function 'shortcuts-p
:accelerator "control-up")
(make-instance 'capi:menu-item
:title "display second text"
:callback 'second-text-msg
:callback-type :interface
:enabled-function 'shortcuts-p
:accelerator "control-down")))
(defun first-text-msg (intf)
(capi:display-message (capi:text-input-pane-text (pane1 intf))))
(defun second-text-msg (intf)
(capi:display-message (capi:text-input-pane-text (pane2 intf))))
(defparameter *example-pane* (make-instance 'example))
(capi:display *example-pane*)