CLIM mail archive

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

question about interface



    Date: Sat, 6 Jun 1992 05:04+0200
    From: unido!aol.com!trinkos

    I'm porting a large project from dw: to clim and I have some questions
    1) Is there an easy way to alphabetize commands in menus

If you mean "sorting in alphabetical order" by "alphabetize", have a look at the
code below, it only uses documented CLIM features. I wrote it half a year ago
or so, but I tink it still works (but beware: only tested for Symbolics' CLIM implementation).

--------------------
(defun sort-command-table-menu-items (command-table sorting-predicate
				      &optional (sorting-key #'identity))
  "removes all menu items and re-inserts them in a sorted way"
  (let ((menu-items NIL))
    (map-over-command-table-menu-items
      #'(lambda (menu-item-name keystroke type-and-value)
	  ;; create a list that can be used as argument list to add-menu-item-to-command-table
	  (push (list menu-item-name (first type-and-value) (second type-and-value)
		      :keystroke keystroke)
		menu-items))
      command-table)
    (setq menu-items (sort menu-items sorting-predicate
			   :key #'(lambda (menu-item-description)
				    (funcall sorting-key (first menu-item-description)))))
    (dolist (menu-item-description menu-items)
      (remove-menu-item-from-command-table command-table (first menu-item-description))
      (apply 'add-menu-item-to-command-table command-table menu-item-description))))
--------------------


    2) How do you attach mouse gestures to menu commands--ie have the menu item
    respond differently to mouse left, right, etc.

I suggest writing presentation-translators to the command presentation type.
Keep in mind, that the command presentation type takes a command-table as 
parameter, i.e., a command ptype could look like 
(COMMAND :COMMAND-TABLE clim-demo::lisp-listener).
In the translator you can specify a gesture. There are several predefine gesture names,
e.g. :SELECT, :DESCRIBE. You can define new ones with DEFINE-GESTURE-NAME. See the
doc for more info about that topic.


Markus Fischer, MF@SGER.UUCP              Mergenthaler Allee 77-81
Consulting Services                       W-6236 Eschborn, Germany
Symbolics Systemhaus GmbH                 Phone: +49 6196 47220, Fax 481116


References:

Main Index | Thread Index