mod/maxgui.mod/fltkmaxgui.mod/src/Fl_Menu_.cxx
int Fl_Menu_::find_index(const char *pathname) const {
  char menupath[1024] = "";	// File/Export
  for ( int t=0; t < size(); t++ ) {
    Fl_Menu_Item *m = menu_ + t;
    if (m->flags&FL_SUBMENU) {
      // IT'S A SUBMENU
      // we do not support searches through FL_SUBMENU_POINTER links
      if (menupath[0]) strlcat(menupath, "/", sizeof(menupath));
      strlcat(menupath, m->label(), sizeof(menupath));
      if (!strcmp(menupath, pathname)) return(t);
    } else {
      if (!m->label()) {
	// END OF SUBMENU? Pop back one level.
	char *ss = strrchr(menupath, '/');
	if ( ss ) *ss = 0;
	else menupath[0] = '\0';
	continue;
      }
      // IT'S A MENU ITEM
      char itempath[1024];	// eg. Edit/Copy
      strcpy(itempath, menupath);
      if (itempath[0]) strlcat(itempath, "/", sizeof(itempath));
      strlcat(itempath, m->label(), sizeof(itempath));
      if (!strcmp(itempath, pathname)) return(t);
    }
  }
  return(-1);
}
/**
 Find the menu item index for a given menu \p pathname, such as "Edit/Copy".
 
 This method finds a menu item's index position for the given menu pathname,
 also traversing submenus, but not submenu pointers.

 To get the menu item pointer for a pathname, use find_item()

 \param pathname The path and name of the menu item index to find
 \returns        The index of the matching item, or -1 if not found.
 \see            item_pathname()

*/
Find the menu item index for a given menu \p pathname, such as "Edit/Copy".
This method finds a menu item's index position for the given menu pathname,
also traversing submenus, but not submenu pointers.

To get the menu item pointer for a pathname, use find_item()

\param pathname The path and name of the menu item index to find
\returns        The index of the matching item, or -1 if not found.
Find the menu item index for a given menu \ p pathname such as " Edit / Copy " . This method finds a menu item ' s index position for the given menu pathname also traversing submenus but not submenu pointers . To get the menu item pointer for a pathname use find_item () \ param pathname The path and name of the menu item index to find \ returns The index of the matching item or - 1 if not found .
int Fl_Menu_::find_index(const char *pathname) const {
  char menupath[1024] = "";	
  for ( int t=0; t < size(); t++ ) {
    Fl_Menu_Item *m = menu_ + t;
    if (m->flags&FL_SUBMENU) {
      if (menupath[0]) strlcat(menupath, "/", sizeof(menupath));
      strlcat(menupath, m->label(), sizeof(menupath));
      if (!strcmp(menupath, pathname)) return(t);
    } else {
      if (!m->label()) {
	char *ss = strrchr(menupath, '/');
	if ( ss ) *ss = 0;
	else menupath[0] = '\0';
	continue;
      }
      char itempath[1024];	
      strcpy(itempath, menupath);
      if (itempath[0]) strlcat(itempath, "/", sizeof(itempath));
      strlcat(itempath, m->label(), sizeof(itempath));
      if (!strcmp(itempath, pathname)) return(t);
    }
  }
  return(-1);
}
int Fl_Menu_ :: find_index ( const char * pathname ) const { char menupath [ 1024 ] = " " ; for ( int t = 0 ; t < size ( ) ; t ++ ) { Fl_Menu_Item * m = menu_ + t ; if ( m -> flags & FL_SUBMENU ) { if ( menupath [ 0 ] ) strlcat ( menupath , " " , sizeof ( menupath ) ) ; strlcat ( menupath , m -> label ( ) , sizeof ( menupath ) ) ; if ( ! strcmp ( menupath , pathname ) ) return ( t ) ; } else { if ( ! m -> label ( ) ) { char * ss = strrchr ( menupath , ' ' ) ; if ( ss ) * ss = 0 ; else menupath [ 0 ] = ' \0 ' ; continue ; } char itempath [ 1024 ] ; strcpy ( itempath , menupath ) ; if ( itempath [ 0 ] ) strlcat ( itempath , " " , sizeof ( itempath ) ) ; strlcat ( itempath , m -> label ( ) , sizeof ( itempath ) ) ; if ( ! strcmp ( itempath , pathname ) ) return ( t ) ; } } return ( -1 ) ; }
Find the menu item index for a given menu \p pathname, such as "Edit/Copy".
Find the menu item index for a given menu \ p pathname such as " Edit / Copy " .
// File/Export // IT'S A SUBMENU // we do not support searches through FL_SUBMENU_POINTER links // END OF SUBMENU? Pop back one level. // IT'S A MENU ITEM // eg. Edit/Copy