void OnHotkeyEntryTakeFocus()
 {
     cancelButton.Disabled = manager.GetFirstDuplicate(definition.Name, currentHotkey, definition) != null;
 }
        static void BindHotkeyPref(HotkeyDefinition hd, HotkeyManager manager, Widget template, Widget parent, Widget remapDialogRoot, Widget remapDialogPlaceholder)
        {
            var key = template.Clone() as Widget;

            key.Id        = hd.Name;
            key.IsVisible = () => true;

            key.Get <LabelWidget>("FUNCTION").GetText = () => hd.Description + ":";

            var remapButton = key.Get <ButtonWidget>("HOTKEY");

            remapButton.GetText = () => manager[hd.Name].GetValue().DisplayString();

            if (manager.GetFirstDuplicate(hd.Name, manager[hd.Name].GetValue(), hd) != null)
            {
                remapButton.GetColor = () => ChromeMetrics.Get <Color>("HotkeyColorInvalid");
            }

            remapButton.OnClick = () =>
            {
                remapDialogRoot.RemoveChildren();

                if (remapButton.IsHighlighted())
                {
                    remapButton.IsHighlighted = () => false;

                    if (remapDialogPlaceholder != null)
                    {
                        remapDialogPlaceholder.Visible = true;
                    }

                    return;
                }

                if (remapDialogPlaceholder != null)
                {
                    remapDialogPlaceholder.Visible = false;
                }

                var siblings = parent.Children;
                foreach (var sibling in siblings)
                {
                    var button = sibling.GetOrNull <ButtonWidget>("HOTKEY");
                    if (button != null)
                    {
                        button.IsHighlighted = () => false;
                    }
                }

                remapButton.IsHighlighted = () => true;

                Ui.LoadWidget("HOTKEY_DIALOG", remapDialogRoot, new WidgetArgs
                {
                    {
                        "onSave", () =>
                        {
                            remapButton.GetText  = () => manager[hd.Name].GetValue().DisplayString();
                            remapButton.GetColor = () => ChromeMetrics.Get <Color>("ButtonTextColor");
                        }
                    },
                    { "hotkeyDefinition", hd },
                    { "hotkeyManager", manager },
                });
            };

            parent.AddChild(key);
        }