Lisp HUG Maillist Archive

CAPI: Menus in external variable for define-interface

Hi all,

How to move menus from define-interface :menus section to external variable to be able to reuse them in another interface?

For example:

(capi:define-interface test4 ()
  ()
  (:menus
   (colors-menu "Colors"
                ((:component
                  (:red :green :blue)
                  :interaction :single-selection
                  :print-function
                  'string-capitalize)
                 more-colors-menu))
   (more-colors-menu "More Colors"
                     (:pink :yellow :cyan)
                     :print-function
                     'string-capitalize))
  (:menu-bar colors-menu more-colors-menu)
  (:default-initargs :title "Test4"))


Here I want colors-menu and more-colors-menu to be used by another interface as well.

Br,
/Alexey

Re: CAPI: Menus in external variable for define-interface

Unable to parse email body. Email id is 14627

Re: CAPI: Menus in external variable for define-interface

Thanks, the version with mixin works perfectly!

Br,
/Alexey

On Wed, Oct 25, 2017 at 6:21 PM, Dmitry Ivanov <dmitry502@list.ru> wrote:
Alexey Veretennikov wrote on Wed, 25 Oct 2017 16:45:40 +0200 17:45:

| How to move menus from define-interface :menus section to external
| variable to be able to reuse them in another interface?
|...snip...|
| Here I want colors-menu and more-colors-menu to be used by another
| interface as well.

Something like this:

(defun more-colors-menu ()
  (make-instance 'capi:menu
    :title "More Colors"
    :items '(:pink :yellow :cyan)
    :print-function 'string-capitalize))

(defmethod initialize-instance :after ((interface test4) &key)
  (push (more-colors-menu) (capi:interface-menu-bar-items interface)))
--
Sincerely,
Dmitry Ivanov
lisp.ystok.ru

Updated at: 2020-12-10 08:30 UTC