Re: [spr30567] HELP on component Menu Bar...

Ken Cheetham <[email protected]> Tue, 23 Aug 2005 21:05:58 -0700
Newsgroups gmane.lisp.allegro
Message-ID <[email protected]>
  I´m using the menu editor and i´ve introduced the call to the function
  in the corresponding "value" field (with the desired item selected),
  but  when i run the GUI and press that item inside the menubar i get
  this error about the number of the parameters...

  Error: INICIAR_LISTA got 1 arg, wanted 2 args.
  [condition type: PROGRAM-ERROR]

  the declaration of the function is as follows:
  (defun iniciar_lista (dialog widget))

  the function works fine calling it from an on-click event from a
  button component. I´ve read the Allegro´s documentation about menubar
  and the examples it contains, and cannot remove the problem....

The on-click property of a menu doesn't work quite the same as the
on-click property of a widget, as explained on the doc page for
on-click.  An on-click function for a widget takes two arguments, for
the dialog and the widget, as your function does.  An on-click
function for a menu instead takes three arguments, for the menu, the
menu-item, and the window that the menu is on.

But the value that you enter into the "value" field of a menu-item in
the menu editor is not an on-click function.  Only a menu has an
on-click function, which it applies to the menu-item that is picked.
In the menu editor, select a parent menu-item and see that it has an
on-click value toward the bottom of the dialog.  The default value
shown there will be funcall-menu-item-with-window.  This means that
when the user picks a menu-item on that menu, the function
funcall-menu-item-with-window will be called with the menu-item that
they picked.  funcall-menu-item-with-window is a built-in function
that assumes that the value of the menu-item is a function, which it
then calls with a single argument, which is the window that the menu
is on.

If your code that is called by the menu-items can work when passed
only the window that the menu is on, then you can keep the default
on-click function of the menu, and make the value of each menu-item be
a function that takes just one argument (for the window).  Otherwise,
you'll need to change the on-click function of the menu to a custom
function that you write, and which takes three arguments (the menu,
the menu-item, and the window that the menu is on).

[This request has been assigned the tracking number spr30567.
For efficiency, please mention this number in the title of future
messages concerning it.  Also please cc: [email protected] so
that someone else can handle your message if I am away.]

Ken Cheetham                          [email protected]
Franz Inc.                            Voice: (510) 452-2000 x124
555 Twelfth Street, Suite 1450        Fax:   (510) 452-0182
Oakland, CA  94607                    Web:   http://www.franz.com/