def _getMenuIndex(values, current, defaultIndex = 1):
    """
    Retrieves the menu index corresponding to the current value selected amongst values.
    If the value is invalid, returns the defaultIndex.
    """
    try:
        # Note: menu index is 1-based.
        return values.index(current) + 1
    except:
        return defaultIndex