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

Large menus



#|
This code should create a menu with 2 items.

The first is a 'separator' "-".

The second is a menu-rebuilder which manipulates the menu to have 92 items,
the integers 0 through 89, and the original 2 items.

Each of the integer menu-items has an update function that unconditionally
disables the menu-item.

So how come (at least on my mac) only the first 31 [0-30] are disabled?
|#

;Choose the second menu-item and then look at the menu again.
;Only 31 of the items are disabled.

;(menu-deinstall (find-menu "Sample"))
(menu-install
  (make-instance 'menu
    :menu-title "Sample"
    :menu-items
    (list
      (make-instance 'menu-item :menu-item-title "-")
      (make-instance 'menu-item
        :menu-item-title "Build Huge Menu"
        :menu-item-action
        #'(lambda ()
            (let* ((menu (find-menu "Sample"))
                   (items (menu-items menu))
                   (keep (subseq items (- (length items) 2))))
              (apply #'remove-menu-items menu items)
              (setq items nil)
              (dotimes (i 90)
                (push
                  (make-instance 'menu-item
                    :menu-item-title (format nil "~A" i)
                    :menu-item-action
                    #'(lambda (m) (print (menu-item-title m)))
                    :update-function
                    #'(lambda (m) (menu-item-disable m)))  ;<------
                  items))
              (apply #'add-menu-items menu (append (nreverse items)
keep))))))))


#|

SYSTEM CONFIGURATION

Mac Quadra 700
System 7.0.1  
32-bit enabled
20M Ram
45M Virtual
Menubar on Apollow 2-page gray-scale.
Debugger on second monitor which is Apple 12" RGB.
Monitors configured:
------------------ --------
|                | |      |
|                | |      |
|                | |      |
|                | |      |
|                | --------
|                |
|                |
|                |
------------------

|#

-- 
--
-- "TANSTAAFL" Rich lynch@ils.nwu.edu