Guide API
Skip to main content

alt

Function alt 

Source
pub fn alt(c: char) -> KeyEvent
Expand description

Build an Alt+<char> KeyEvent for use as a menu accelerator.

This is the most common accelerator form for menu items. Pass the result to MenuBuilder::command_key or MenuBuilder::submenu, or store it in MenuItem::Command::key_code / MenuItem::SubMenu::key_code:

use tvision_rs::menu::{Menu, alt};
use tvision_rs::command::Command;

let menu = Menu::builder()
    .submenu("~F~ile", alt('f'), |m| {
        m.command_key("E~x~it", Command::QUIT, alt('x'), "Alt-X")
    })
    .build();

For other key combinations (e.g. function keys) construct a KeyEvent directly using KeyEvent::from(Key::F(n)).