wxMaxima
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions
SymbolShortcutDialog Class Reference

Asks the user to press the keys that should type a symbol. More...

#include <SymbolShortcutDialog.h>

Inheritance diagram for SymbolShortcutDialog:
[legend]
Collaboration diagram for SymbolShortcutDialog:
[legend]

Public Types

using UsageLookup = std::function< wxString(const wxString &rawShortcut)>
 Describes what a shortcut is already used for: a menu entry's or another symbol's name, or an empty string if it is free.
 

Public Member Functions

 SymbolShortcutDialog (wxWindow *parent, const wxString &symbol, const wxString &currentShortcut, UsageLookup usage)
 
const wxString & GetShortcut () const
 The recorded shortcut, in the raw form wxm::SymbolShortcut stores.
 
bool RecordKey (const wxKeyEvent &event)
 Records a key press as if the user had pressed it.
 

Static Public Member Functions

static wxString MenuItemUsingShortcut (const wxMenuBar *menuBar, const wxString &rawShortcut)
 What the menu bar already uses this shortcut for.
 
static wxMenuBar * FindMenuBar (wxWindow *window)
 The menu bar of the main window window belongs to, if any.
 
static UsageLookup MakeUsageLookup (wxWindow *window, std::vector< wxm::SymbolShortcut > shortcuts, const wxString &symbol)
 The usual UsageLookup: the menu entries of window's main window and the symbols in shortcuts other than symbol.
 

Detailed Description

Asks the user to press the keys that should type a symbol.

The keys are caught before any control of the dialog sees them, so a combination like Ctrl+Alt+T is recorded instead of acting on the dialog. Enter, Escape and Tab without Ctrl or Alt keep working as usual: they aren't usable as a symbol's shortcut anyway (see wxm::IsUsableShortcut()).

The dialog only records. What the shortcut is currently used for is asked of the function passed to the constructor, which is how the dialog can warn about a clash with a menu or another symbol without knowing where the shortcuts are kept.

Member Function Documentation

◆ GetShortcut()

const wxString & SymbolShortcutDialog::GetShortcut ( ) const
inline

The recorded shortcut, in the raw form wxm::SymbolShortcut stores.

Empty if the user removed the shortcut.

◆ MenuItemUsingShortcut()

wxString SymbolShortcutDialog::MenuItemUsingShortcut ( const wxMenuBar *  menuBar,
const wxString &  rawShortcut 
)
static

What the menu bar already uses this shortcut for.

The label of the menu entry it belongs to (without the "&" mnemonics), or an empty string.

◆ RecordKey()

bool SymbolShortcutDialog::RecordKey ( const wxKeyEvent &  event)

Records a key press as if the user had pressed it.

Returns whether it was a usable shortcut. The test drives the dialog through this, as synthesising real key presses is not portable.


The documentation for this class was generated from the following files: