Re: [AD] Menus and Callbacks

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Sun, 2004-11-07 at 14:10 -0800, Dustin Dettmer wrote:
> > typedef struct MENU
> > 
> >    char *text;          - the text to display for
> the menu item
> >    int (*proc)(void);   - called when the menu item
> is clicked
> >    struct MENU *child;  - nested child menu
> >    int flags;           - disabled or checked state
> >    void *dp;            - pointer to any data you
> need
> 
> >    Structure used to hold an entry of a menu. Read
> chapter "GUI routines",
> >    section "GUI menus" for a description on how to
> obtain/use this structure.
> 
> Wouldnt it make sense for proc to get a copy of dp? 
> The docs mention that dp is free for you to use, but
> you cant.  Not passing dp to proc means that all menus
> created using allegro's menuing system *must* be of
> static length.  Static length menus are rather
> undesirable imho.
> 
> I ran into this issue creating an editor that requires
> an arbitrary amount of objects that the user can add,
> remove and modify.  Upon trying to make a submenu with
> a list of each object for modifying, I realised it was
> impossible and in the end used a hackish callback
> system which defined 300+ extra functions and put a
> limit on the amount of objects the editor can handle
> (300).  This problem could very easily be avoided if
> proc was handed a copy of dp, so that the callback
> function could 'know' which menu option called it.
> 

Lookup "active_menu" in the docs. Does it help?

-- 
Elias Pschernig





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/