Mike Werner wrote:
> Fl_Menu_Item menu_Screen[] = {
>  {" Default Window", 0xff09,  (Fl_Callback*)cb_Screen_Default, 0, 12, 0, 0, 
> 11, 7},
>  {" Reduced Graphics", 0x77,  (Fl_Callback*)cb_Screen_Reduced, 0, 8, 0, 0, 
> 11, 7},
>  {" Full Screen Graphics", 0x71,  (Fl_Callback*)cb_Screen_Full, 0, 136, 0, 0, 
> 11, 7},
>  {" 1 Viewport", 0x31,  (Fl_Callback*)cb_Split_1, 0, 8, 0, 0, 11, 7},
>  {" 3 Viewports", 0x33,  (Fl_Callback*)cb_Split_3, 0, 8, 0, 0, 11, 7},
>  {" 4 Viewports", 0x34,  (Fl_Callback*)cb_Split_4, 0, 136, 0, 0, 11, 7},
>  {"Logos", 0x6c,  (Fl_Callback*)cb_Logos, 0, 0, 0, 0, 11, 7},
>  {0}
> }
> 
> Above is the actual code generated by Fluid for my pulldown menu.
> The 4th menu item, labeled " 1 Viewport", refers to a callback called
> "cb_Split_1". How do I "invoke the callback", from within the callback
> definition panel of another widget? What is the exact syntax?  Thanks.

        Treat it just like a regular array.

        If you want to refer to the menu item by its index number,
        offhand I'd think something like:

menu_Screen[3].do_callback(w);

        ..in the callback panel of the other widgets would work,
        where 'w' is the first argument passed to your callback.
        I think it's supposed to be the menu widget itself.
        So if your menu widget is named 'mymenu', then I guess
        you can use that name in place of 'w'.

        For a more precise example, I'd need more example code
        to see what you have.

        Or, if you prefer not to use hard coded index numbers
        (I know I wouldn't) then walk the array dynamically to
        find the item by name, eg:

for ( int t=0; menu_Screen[t].label(); t++ ) {
    if ( strcmp(menu_Screen[t].label(), "1 Viewports") == 0 ) {
        menu_Screen[t].do_callback();
    }
}

        This 'lookup' is essentially what find_item() does,
        but if you're using an 8 year old version of fltk,
        it may not have find_item(), so use the above instead.

        Either make a function that does the above and call it,
        or put that code right in the panel. (I'm assuming fluid 1.0.11
        allows you to put code in the callback panel. I don't have a version
        of fluid that old here.. I'm not I it would even compile on any
        of my current machines)

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to