<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-text-flowed" style="font-family: -moz-fixed;
font-size: 12px;" lang="x-unicode">From Greg Bennett running sbcl
1.4.11 (64bit) under linux mint 18.1 (64bit)
<br>
and using mcclim-2019-0202-git, as far as I can tell.
<br>
<br>
I'm trying to learn how to add and remove menus from an existing
menubar<br>
which I presume is done through its associated command-table. In
the interests of<br>
completeness I include the contents of the example file. If this
is a silly thing to do,<br>
let me know.<br>
<br>
From that git, I'm using the file Examples/menutest.lisp as a
basis for experiments with menus,
<br>
menubars, adding and removing menus.
<br>
<br>
;; START File contents of Examples/menutest.lisp
<br>
;;; (c) copyright 2000 by
<br>
;;; Robert Strandh (<a class="moz-txt-link-abbreviated"
href="mailto:robert.strandh@gmail.com">robert.strandh@gmail.com</a>)
<br>
<br>
;;; This library is free software; you can redistribute it and/or
<br>
;;; modify it under the terms of the GNU Library General Public
<br>
;;; License as published by the Free Software Foundation; either
<br>
;;; version 2 of the License, or (at your option) any later
version.
<br>
;;;
<br>
;;; This library is distributed in the hope that it will be
useful,
<br>
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
<br>
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU
<br>
;;; Library General Public License for more details.
<br>
;;;
<br>
;;; You should have received a copy of the GNU Library General
Public
<br>
;;; License along with this library; if not, write to the
<br>
;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
<br>
;;; Boston, MA 02111-1307 USA.
<br>
<br>
(defpackage #:menutest
<br>
(:use :clim :clim-extensions :clim-lisp)
<br>
(:export #:menutest))
<br>
<br>
(in-package #:menutest)
<br>
<br>
(define-application-frame menutest ()
<br>
()
<br>
(:menu-bar menubar-command-table)
<br>
(:panes
<br>
(screen :application
<br>
:display-time nil
<br>
:text-style (make-text-style :sans-serif :roman
:normal)))
<br>
(:layouts
<br>
(defaults (vertically () screen))))
<br>
<br>
(define-menutest-command com-file ()
<br>
(format <b class="moz-txt-star"><span class="moz-txt-tag">*</span>standard-output<span
class="moz-txt-tag">*</span></b> "You pressed the File
button.~%")
<br>
(finish-output <b class="moz-txt-star"><span
class="moz-txt-tag">*</span>standard-output<span
class="moz-txt-tag">*</span></b>))
<br>
<br>
(define-menutest-command com-hello ()
<br>
(format <b class="moz-txt-star"><span class="moz-txt-tag">*</span>standard-output<span
class="moz-txt-tag">*</span></b> "You pressed the Hello
button.~%")
<br>
(finish-output <b class="moz-txt-star"><span
class="moz-txt-tag">*</span>standard-output<span
class="moz-txt-tag">*</span></b>))
<br>
<br>
(define-menutest-command com-hi ()
<br>
(format <b class="moz-txt-star"><span class="moz-txt-tag">*</span>standard-output<span
class="moz-txt-tag">*</span></b> "You pressed the Hi
button.~%")
<br>
(finish-output <b class="moz-txt-star"><span
class="moz-txt-tag">*</span>standard-output<span
class="moz-txt-tag">*</span></b>))
<br>
<br>
(make-command-table 'buffer-command-table
<br>
:errorp nil
<br>
:menu '(("Hello there" :command com-hello)
<br>
("Hi there" :command com-hi)))
<br>
<br>
(make-command-table 'menubar-command-table
<br>
:errorp nil
<br>
:menu '(("Buffer" :menu buffer-command-table)
<br>
("File" :command com-file)))
<br>
;; END file contents
<br>
<br>
Inside the package menutest, I added this form:
<br>
<br>
(defun run-menutest (thread-name)
<br>
(flet ((run ()
<br>
(let ((frame (make-application-frame 'menutest)))
<br>
(run-frame-top-level frame))))
<br>
(sb-thread::make-thread #'run :name thread-name)))
<br>
<br>
so that I can create the frame and keep the listener.
<br>
<br>
With Daniel's help I can see what is on the command-table:<br>
(let (foo)<br>
(map-over-command-table-commands<br>
(lambda (elt) (push elt foo))<br>
(frame-command-table (find-application-frame 'menutest)))
;; from CLIM 2 P201 [f-c-t], P178 [f-a-f] 'menutest<br>
;;; from define application-frame itself<br>
(nreverse foo))<br>
;; -><br>
<br>
(COM-FILE COM-HELLO COM-HI CLIM-INTERNALS::COM-NULL-COMMAND<br>
CLIM-INTERNALS::COM-HELP CLIM-INTERNALS::COM-DESCRIBE<br>
CLIM-INTERNALS::COM-DESCRIBE-PRESENTATION<br>
CLIM-TAB-LAYOUT:COM-SWITCH-TO-TAB-PAGE<br>
CLIM-TAB-LAYOUT:COM-REMOVE-TAB-PAGE)<br>
<br>
And I seem to be able to add a command:<br>
(define-menutest-command com-RWO ()<br>
(format *standard-output* "Fearless Leader~%")<br>
(finish-output *standard-output*))<br>
<br>
;; followed by [CLIM2.2 P219]<br>
(add-menu-item-to-command-table<br>
(frame-command-table (find-application-frame 'menutest))<br>
"RWO"<br>
:command<br>
(cons 'COM-RWO (list ())))<br>
;; -> NIL<br>
;; Does NIL indicate something is wrong, I wonder ?<br>
<br>
;; Rerun (let ..)<br>
(COM-FILE COM-HELLO COM-HI COM-RWO
CLIM-INTERNALS::COM-NULL-COMMAND<br>
CLIM-INTERNALS::COM-HELP CLIM-INTERNALS::COM-DESCRIBE<br>
CLIM-INTERNALS::COM-DESCRIBE-PRESENTATION<br>
CLIM-TAB-LAYOUT:COM-SWITCH-TO-TAB-PAGE<br>
CLIM-TAB-LAYOUT:COM-REMOVE-TAB-PAGE)<br>
;;; and there it seems to be.<br>
<br>
I had hoped that the application-frame would now show RWO. <br>
<br>
Do I have to explicitly redisplay the items of the frame's
menubar, perhaps ?<br>
<br>
My attempts to use (display-command-table-menu ..) each yield a <br>
no applicable method error.<br>
<br>
I would appreciate pointers to what I am still missing in
exploring command-tables.
<br>
<br>
Cheers /Greg Bennett
<br>
<br>
</div>
</body>
</html>