wxMaxima
Loading...
Searching...
No Matches
Functions
MenuHelpString.cpp File Reference

Implements MenuHelpString(); see MenuHelpString.h for the rationale. More...

#include "MenuHelpString.h"
#include <wx/menu.h>
#include <wx/menuitem.h>
Include dependency graph for MenuHelpString.cpp:

Functions

wxString MenuHelpString (wxMenu *menu, int id)
 Returns the help string of the item with the given id inside menu.
 

Detailed Description

Implements MenuHelpString(); see MenuHelpString.h for the rationale.

Function Documentation

◆ MenuHelpString()

wxString MenuHelpString ( wxMenu *  menu,
int  id 
)

Returns the help string of the item with the given id inside menu.

This is what wxMaxima shows in the status bar while a menu item is highlighted. It exists as a separate, testable function because wxMenu::GetHelpString() asserts ("item" failed) in wxWidgets 3.3 when the highlighted id is not an item of that menu – a situation the native menu code (notably on Windows) can produce for menu/submenu titles or ids that belong to another menu. Instead of relying on GetHelpString()'s not-found behaviour we look the item up with wxMenu::FindItem(), which recurses into submenus and simply returns nullptr when nothing matches.

Parameters
menuThe menu whose item is being highlighted (may be nullptr).
idThe highlighted item id (ids <= 0 are treated as "no item").
Returns
The item's help text, or an empty string when there is no matching item. Never asserts.