void SetupInputButton(ref Label label, ref InputKeyButton button, GameBoyKeys key) { label = new Label(key.ToString()); button = new InputKeyButton { Label = Program.settings.GetKey(key).ToString(), GameBoyKey = key }; button.Pressed += ActivateButton; button.KeyPressEvent += OnKeyPress; masterContainer.Attach(label, 0, buttonCount, 1, 1); masterContainer.Attach(button, 1, buttonCount, 1, 1); buttonCount++; }
void OnKeyPress(object sender, KeyPressEventArgs args) { InputKeyButton ikb = (InputKeyButton)sender; if (Configuration.Settings.MapGtkToSDL(args.Event.Key) == null) { return; } Focus = null; //Unfocus the button ikb.Label = args.Event.Key.ToString(); Program.settings.SetKey(ikb.GameBoyKey, args.Event.Key); }