mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 22:55:48 +01:00
Support F-keys & a couple more system keys
This commit is contained in:
parent
5c39467879
commit
083aee1588
2 changed files with 185 additions and 18 deletions
|
|
@ -1309,6 +1309,124 @@ id processAcceleratorKey(const char *key) {
|
|||
if( STREQ(key, "Page Down") ) {
|
||||
return strunicode(0x21df);
|
||||
}
|
||||
if( STREQ(key, "F1") ) {
|
||||
return strunicode(0xf704);
|
||||
}
|
||||
if( STREQ(key, "F2") ) {
|
||||
return strunicode(0xf705);
|
||||
}
|
||||
if( STREQ(key, "F3") ) {
|
||||
return strunicode(0xf706);
|
||||
}
|
||||
if( STREQ(key, "F4") ) {
|
||||
return strunicode(0xf707);
|
||||
}
|
||||
if( STREQ(key, "F5") ) {
|
||||
return strunicode(0xf708);
|
||||
}
|
||||
if( STREQ(key, "F6") ) {
|
||||
return strunicode(0xf709);
|
||||
}
|
||||
if( STREQ(key, "F7") ) {
|
||||
return strunicode(0xf70a);
|
||||
}
|
||||
if( STREQ(key, "F8") ) {
|
||||
return strunicode(0xf70b);
|
||||
}
|
||||
if( STREQ(key, "F9") ) {
|
||||
return strunicode(0xf70c);
|
||||
}
|
||||
if( STREQ(key, "F10") ) {
|
||||
return strunicode(0xf70d);
|
||||
}
|
||||
if( STREQ(key, "F11") ) {
|
||||
return strunicode(0xf70e);
|
||||
}
|
||||
if( STREQ(key, "F12") ) {
|
||||
return strunicode(0xf70f);
|
||||
}
|
||||
if( STREQ(key, "F13") ) {
|
||||
return strunicode(0xf710);
|
||||
}
|
||||
if( STREQ(key, "F14") ) {
|
||||
return strunicode(0xf711);
|
||||
}
|
||||
if( STREQ(key, "F15") ) {
|
||||
return strunicode(0xf712);
|
||||
}
|
||||
if( STREQ(key, "F16") ) {
|
||||
return strunicode(0xf713);
|
||||
}
|
||||
if( STREQ(key, "F17") ) {
|
||||
return strunicode(0xf714);
|
||||
}
|
||||
if( STREQ(key, "F18") ) {
|
||||
return strunicode(0xf715);
|
||||
}
|
||||
if( STREQ(key, "F19") ) {
|
||||
return strunicode(0xf716);
|
||||
}
|
||||
if( STREQ(key, "F20") ) {
|
||||
return strunicode(0xf717);
|
||||
}
|
||||
if( STREQ(key, "F21") ) {
|
||||
return strunicode(0xf718);
|
||||
}
|
||||
if( STREQ(key, "F22") ) {
|
||||
return strunicode(0xf719);
|
||||
}
|
||||
if( STREQ(key, "F23") ) {
|
||||
return strunicode(0xf71a);
|
||||
}
|
||||
if( STREQ(key, "F24") ) {
|
||||
return strunicode(0xf71b);
|
||||
}
|
||||
if( STREQ(key, "F25") ) {
|
||||
return strunicode(0xf71c);
|
||||
}
|
||||
if( STREQ(key, "F26") ) {
|
||||
return strunicode(0xf71d);
|
||||
}
|
||||
if( STREQ(key, "F27") ) {
|
||||
return strunicode(0xf71e);
|
||||
}
|
||||
if( STREQ(key, "F28") ) {
|
||||
return strunicode(0xf71f);
|
||||
}
|
||||
if( STREQ(key, "F29") ) {
|
||||
return strunicode(0xf720);
|
||||
}
|
||||
if( STREQ(key, "F30") ) {
|
||||
return strunicode(0xf721);
|
||||
}
|
||||
if( STREQ(key, "F31") ) {
|
||||
return strunicode(0xf722);
|
||||
}
|
||||
if( STREQ(key, "F32") ) {
|
||||
return strunicode(0xf723);
|
||||
}
|
||||
if( STREQ(key, "F33") ) {
|
||||
return strunicode(0xf724);
|
||||
}
|
||||
if( STREQ(key, "F34") ) {
|
||||
return strunicode(0xf725);
|
||||
}
|
||||
if( STREQ(key, "F35") ) {
|
||||
return strunicode(0xf726);
|
||||
}
|
||||
if( STREQ(key, "Insert") ) {
|
||||
return strunicode(0xf727);
|
||||
}
|
||||
if( STREQ(key, "PrintScreen") ) {
|
||||
return strunicode(0xf72e);
|
||||
}
|
||||
if( STREQ(key, "ScrollLock") ) {
|
||||
return strunicode(0xf72f);
|
||||
}
|
||||
if( STREQ(key, "NumLock") ) {
|
||||
return strunicode(0xf739);
|
||||
}
|
||||
|
||||
return str(key);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,24 +30,73 @@ func main() {
|
|||
|
||||
menu.SubMenu("Test Submenu", []*menu.MenuItem{
|
||||
menu.SubMenu("Accelerators", []*menu.MenuItem{
|
||||
menu.TextWithAccelerator("Shift accelerator", "Shift", menu.ShiftAccel("o")),
|
||||
menu.TextWithAccelerator("Control accelerator", "Control", menu.ControlAccel("o")),
|
||||
menu.TextWithAccelerator("Command accelerator", "Command", menu.CmdOrCtrlAccel("o")),
|
||||
menu.TextWithAccelerator("Option accelerator", "Option", menu.OptionOrAltAccel("o")),
|
||||
menu.TextWithAccelerator("Backspace", "Backspace", menu.Accel("Backspace")),
|
||||
menu.TextWithAccelerator("Tab", "Tab", menu.Accel("Tab")),
|
||||
menu.TextWithAccelerator("Return", "Return", menu.Accel("Return")),
|
||||
menu.TextWithAccelerator("Escape", "Escape", menu.Accel("Escape")),
|
||||
menu.TextWithAccelerator("Left", "Left", menu.Accel("Left")),
|
||||
menu.TextWithAccelerator("Right", "Right", menu.Accel("Right")),
|
||||
menu.TextWithAccelerator("Up", "Up", menu.Accel("Up")),
|
||||
menu.TextWithAccelerator("Down", "Down", menu.Accel("Down")),
|
||||
menu.TextWithAccelerator("Space", "Space", menu.Accel("Space")),
|
||||
menu.TextWithAccelerator("Delete", "Delete", menu.Accel("Delete")),
|
||||
menu.TextWithAccelerator("Home", "Home", menu.Accel("Home")),
|
||||
menu.TextWithAccelerator("End", "End", menu.Accel("End")),
|
||||
menu.TextWithAccelerator("Page Up", "Page Up", menu.Accel("Page Up")),
|
||||
menu.TextWithAccelerator("Page Down", "Page Down", menu.Accel("Page Down")),
|
||||
menu.SubMenu("Modifiers", []*menu.MenuItem{
|
||||
menu.TextWithAccelerator("Shift accelerator", "Shift", menu.ShiftAccel("o")),
|
||||
menu.TextWithAccelerator("Control accelerator", "Control", menu.ControlAccel("o")),
|
||||
menu.TextWithAccelerator("Command accelerator", "Command", menu.CmdOrCtrlAccel("o")),
|
||||
menu.TextWithAccelerator("Option accelerator", "Option", menu.OptionOrAltAccel("o")),
|
||||
}),
|
||||
menu.SubMenu("System Keys", []*menu.MenuItem{
|
||||
menu.TextWithAccelerator("Backspace", "Backspace", menu.Accel("Backspace")),
|
||||
menu.TextWithAccelerator("Tab", "Tab", menu.Accel("Tab")),
|
||||
menu.TextWithAccelerator("Return", "Return", menu.Accel("Return")),
|
||||
menu.TextWithAccelerator("Escape", "Escape", menu.Accel("Escape")),
|
||||
menu.TextWithAccelerator("Left", "Left", menu.Accel("Left")),
|
||||
menu.TextWithAccelerator("Right", "Right", menu.Accel("Right")),
|
||||
menu.TextWithAccelerator("Up", "Up", menu.Accel("Up")),
|
||||
menu.TextWithAccelerator("Down", "Down", menu.Accel("Down")),
|
||||
menu.TextWithAccelerator("Space", "Space", menu.Accel("Space")),
|
||||
menu.TextWithAccelerator("Delete", "Delete", menu.Accel("Delete")),
|
||||
menu.TextWithAccelerator("Home", "Home", menu.Accel("Home")),
|
||||
menu.TextWithAccelerator("End", "End", menu.Accel("End")),
|
||||
menu.TextWithAccelerator("Page Up", "Page Up", menu.Accel("Page Up")),
|
||||
menu.TextWithAccelerator("Page Down", "Page Down", menu.Accel("Page Down")),
|
||||
menu.TextWithAccelerator("Insert", "Insert", menu.Accel("Insert")),
|
||||
menu.TextWithAccelerator("PrintScreen", "PrintScreen", menu.Accel("PrintScreen")),
|
||||
menu.TextWithAccelerator("ScrollLock", "ScrollLock", menu.Accel("ScrollLock")),
|
||||
menu.TextWithAccelerator("NumLock", "NumLock", menu.Accel("NumLock")),
|
||||
}),
|
||||
menu.SubMenu("Function Keys", []*menu.MenuItem{
|
||||
menu.TextWithAccelerator("F1", "F1", menu.Accel("F1")),
|
||||
menu.TextWithAccelerator("F2", "F2", menu.Accel("F2")),
|
||||
menu.TextWithAccelerator("F3", "F3", menu.Accel("F3")),
|
||||
menu.TextWithAccelerator("F4", "F4", menu.Accel("F4")),
|
||||
menu.TextWithAccelerator("F5", "F5", menu.Accel("F5")),
|
||||
menu.TextWithAccelerator("F6", "F6", menu.Accel("F6")),
|
||||
menu.TextWithAccelerator("F7", "F7", menu.Accel("F7")),
|
||||
menu.TextWithAccelerator("F8", "F8", menu.Accel("F8")),
|
||||
menu.TextWithAccelerator("F9", "F9", menu.Accel("F9")),
|
||||
menu.TextWithAccelerator("F10", "F10", menu.Accel("F10")),
|
||||
menu.TextWithAccelerator("F11", "F11", menu.Accel("F11")),
|
||||
menu.TextWithAccelerator("F12", "F12", menu.Accel("F12")),
|
||||
menu.TextWithAccelerator("F13", "F13", menu.Accel("F13")),
|
||||
menu.TextWithAccelerator("F14", "F14", menu.Accel("F14")),
|
||||
menu.TextWithAccelerator("F15", "F15", menu.Accel("F15")),
|
||||
menu.TextWithAccelerator("F16", "F16", menu.Accel("F16")),
|
||||
menu.TextWithAccelerator("F17", "F17", menu.Accel("F17")),
|
||||
menu.TextWithAccelerator("F18", "F18", menu.Accel("F18")),
|
||||
menu.TextWithAccelerator("F19", "F19", menu.Accel("F19")),
|
||||
menu.TextWithAccelerator("F20", "F20", menu.Accel("F20")),
|
||||
menu.TextWithAccelerator("F21", "F21", menu.Accel("F21")),
|
||||
menu.TextWithAccelerator("F22", "F22", menu.Accel("F22")),
|
||||
menu.TextWithAccelerator("F23", "F23", menu.Accel("F23")),
|
||||
menu.TextWithAccelerator("F24", "F24", menu.Accel("F24")),
|
||||
menu.TextWithAccelerator("F25", "F25", menu.Accel("F25")),
|
||||
menu.TextWithAccelerator("F26", "F26", menu.Accel("F26")),
|
||||
menu.TextWithAccelerator("F27", "F27", menu.Accel("F27")),
|
||||
menu.TextWithAccelerator("F28", "F28", menu.Accel("F28")),
|
||||
menu.TextWithAccelerator("F29", "F29", menu.Accel("F29")),
|
||||
menu.TextWithAccelerator("F30", "F30", menu.Accel("F30")),
|
||||
menu.TextWithAccelerator("F31", "F31", menu.Accel("F31")),
|
||||
menu.TextWithAccelerator("F32", "F32", menu.Accel("F32")),
|
||||
menu.TextWithAccelerator("F33", "F33", menu.Accel("F33")),
|
||||
menu.TextWithAccelerator("F34", "F34", menu.Accel("F34")),
|
||||
menu.TextWithAccelerator("F35", "F35", menu.Accel("F35")),
|
||||
}),
|
||||
menu.SubMenu("Standard Keys", []*menu.MenuItem{
|
||||
menu.TextWithAccelerator("Backtick", "Backtick", menu.Accel("`")),
|
||||
menu.TextWithAccelerator("Plus", "Plus", menu.Accel("+")),
|
||||
}),
|
||||
}),
|
||||
&menu.MenuItem{
|
||||
Label: "Disabled Menu",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue