CLIM mail archive

[Prev][Next][Index][Thread]

Command Table Menu Inheritance



    Date: Tue, 1 Feb 1994 14:04 EST
    From: clarisse@iexist.att.com

    When do menu actually inherit commands from command-tables?

    I ignored the following minor inconvenience so far, but
    now that CLIM2.0 is getty much more stable everywhere, may
    be this can be cleaned or clarified:

    "Is the only reliable way to get commands to come up
    predictably in the menu-bar to list them one
    by one, is that to be expected?"

I think you will find that using the :INHERIT-MENU option when you
define the command table will help a lot.

    Below is an example a friend passed to me that does
    not seem to inherit a command where I thought it should.
    (We assume the :MENU option defaults to T as described
    in the documentation.) Any comment?

    Also we experience strange effects when recompiling application
    frame definitions with additional commands, or when dynamically
    adding new definitions in two versions of CLIM2.0 we tried.
    Even when restarting a new frame (after destroying the previous one)
    we do not get the new commands, except those explicitely listed
    one by one. The example below can be used to test these cases as well.

    Olivier Clarisse

    ;;; -*- Mode: LISP; Syntax: ANSI-Common-lisp; Package: CLIM-USER ; Base: 10 -*-

    (in-package "CLIM-USER")

    ;;
    ;; Define an application frame1
    ;;
    ;; It supports a default command table: frame1-command-table
    ;;
    (define-application-frame frame1 ()
      ()
      (:pointer-documentation t)
      (:panes
       (design-area :application))
      (:layouts
       (main
	design-area)))

    ;;
    ;; Define a command for the frame1-command-table
    ;;
    (define-frame1-command (com-exit-frame1 :menu "Exit Frame 1")
	()
      (frame-exit *application-frame*))

    ;;
    ;; Define a second application frame2
    ;;
    ;; Tell it to inherit from the frame1 command table
    ;;
    (define-application-frame frame2 ()
      ()
      (:pointer-documentation t)
      (:panes
       (design-area :application))
      (:layouts
       (main
	design-area))
      (:command-table (frame2
		       :inherit-from (frame1))))

    ;;
    ;; Define a command for the frame2 command table
    ;;
    (define-frame2-command (com-exit-frame2 :menu "Exit Frame 2")
	()
      (frame-exit *application-frame*))

    ;;
    ;; Run the frame
    ;;
    (defun run-frame2 ()
      (let ((frame (make-application-frame 'frame2)))
	(when frame
	  (mp:process-run-function "Frame2" #'run-frame-top-level frame))))
				       

    ;;
    ;; The second frame (frame2) should now have two commands:
    ;; "Exit Frame 1" from its commands table and "Exit Frame 2"
    ;; from the inherited command table. WELL it only has the second
    ;; command in Allegro CLIM2.0 beta and in Lispworks CLIM2.0
    ;; (Version 3.2.21 beta 4).
    ;;

    #|
    ;; Here is a way to force both commands in, why is this necessary?
    (define-application-frame frame2 ()
      ()
      (:pointer-documentation t)
      (:panes
       (design-area :application))
      (:layouts
       (main
	design-area))
      (:command-table (frame2
		       :inherit-from (frame1)
		       :menu (("Exit1" :command (com-exit-frame1) :documentation "Inherited exit")
			  
			      ("Exit2" :command (com-exit-frame2))))))
    |#

References:

Main Index | Thread Index