void FocusKeyDown(Key key) { if (focusWidget == widgets[keyI]) { curHotkey.BaseKey = key; SetButton(widgets[keyI], "Key: " + curHotkey.BaseKey); supressNextPress = true; } else if (focusWidget == widgets[modifyI]) { if (key == Key.ControlLeft || key == Key.ControlRight) { curHotkey.Flags |= 1; } else if (key == Key.ShiftLeft || key == Key.ShiftRight) { curHotkey.Flags |= 2; } else if (key == Key.AltLeft || key == Key.AltRight) { curHotkey.Flags |= 4; } else { curHotkey.Flags = 0; } string flags = HotkeyListScreen.MakeFlagsString(curHotkey.Flags); SetButton(widgets[modifyI], "Modifiers:" + flags); supressNextPress = true; } focusWidget = null; }
void LostFocus() { if (focusWidget == null) { return; } if (focusWidget == widgets[keyI]) { SetButton(widgets[keyI], "Key: " + curHotkey.BaseKey); } else if (focusWidget == widgets[modifyI]) { string flags = HotkeyListScreen.MakeFlagsString(curHotkey.Flags); SetButton(widgets[modifyI], "Modifiers:" + flags); } focusWidget = null; supressNextPress = false; }
public override void Init() { game.Keyboard.KeyRepeat = true; base.Init(); regularFont = new Font(game.FontName, 16, FontStyle.Regular); string flags = HotkeyListScreen.MakeFlagsString(curHotkey.Flags); if (curHotkey.Text == null) { curHotkey.Text = ""; } string staysOpen = curHotkey.StaysOpen ? "yes" : "no"; bool existed = origHotkey.BaseKey != Key.Unknown; widgets = new Widget[] { Make(0, -150, "Key: " + curHotkey.BaseKey, 301, 40, titleFont, BaseKeyClick), Make(0, -100, "Modifiers:" + flags, 301, 40, titleFont, ModifiersClick), MenuInputWidget.Create( game, 0, -35, 500, 30, curHotkey.Text, Anchor.Centre, Anchor.Centre, regularFont, titleFont, new StringValidator(64)), Make(-100, 10, "Input stays open: " + staysOpen, 301, 40, titleFont, LeaveOpenClick), Make(0, 80, existed ? "Save changes" : "Add hotkey", 301, 40, titleFont, SaveChangesClick), Make(0, 130, existed ? "Remove hotkey" : "Cancel", 301, 40, titleFont, RemoveHotkeyClick), MakeBack(false, titleFont, (g, w) => g.SetNewScreen(new PauseScreen(g))), }; }