public ComboBox(DwarfGUI gui, GUIComponent parent) : base(gui, parent) { Values = new List <string>(); CurrentValue = ""; OnLeftClicked += ComboBox_OnLeftPressed; Selector = null; OnSelectionModified += ComboBox_OnSelectionModified; }
private void ComboBox_OnLeftPressed() { if (Selector == null) { Rectangle fieldRect = new Rectangle(GlobalBounds.X, GlobalBounds.Y + GlobalBounds.Height / 2 - GUI.Skin.TileHeight / 2, GlobalBounds.Width, 32); if (fieldRect.Contains(Mouse.GetState().X, Mouse.GetState().Y)) { Selector = new ComboBoxSelector(GUI, this, Values, CurrentValue); GUI.FocusComponent = Selector; Selector.OnSelectionModified += Selector_OnSelectionModified; } } }
private void ComboBox_OnLeftPressed() { if(Selector == null) { Rectangle fieldRect = new Rectangle(GlobalBounds.X, GlobalBounds.Y + GlobalBounds.Height / 2 - GUI.Skin.TileHeight / 2, GlobalBounds.Width, 32); if(fieldRect.Contains(Mouse.GetState().X, Mouse.GetState().Y)) { Selector = new ComboBoxSelector(GUI, this, Values, CurrentValue); GUI.FocusComponent = Selector; Selector.OnSelectionModified += Selector_OnSelectionModified; } } }