mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-26 06:28:35 +01:00
Close other dropdowns when opening a dropdown
This commit is contained in:
parent
8044cb59cb
commit
5aaba0c583
2 changed files with 11 additions and 1 deletions
|
@ -20,6 +20,7 @@ Additions
|
||||||
|
|
||||||
Improvements
|
Improvements
|
||||||
- Allow elements to auto-adjust their size even when their children are aligned oddly
|
- Allow elements to auto-adjust their size even when their children are aligned oddly
|
||||||
|
- Close other dropdowns when opening a dropdown
|
||||||
|
|
||||||
## 6.0.0
|
## 6.0.0
|
||||||
### MLEM
|
### MLEM
|
||||||
|
|
|
@ -42,7 +42,16 @@ namespace MLEM.Ui.Elements {
|
||||||
});
|
});
|
||||||
this.OnAreaUpdated += e => this.Panel.PositionOffset = new Vector2(0, e.Area.Height / this.Scale);
|
this.OnAreaUpdated += e => this.Panel.PositionOffset = new Vector2(0, e.Area.Height / this.Scale);
|
||||||
this.OnOpenedOrClosed += e => this.Priority = this.IsOpen ? 10000 : 0;
|
this.OnOpenedOrClosed += e => this.Priority = this.IsOpen ? 10000 : 0;
|
||||||
this.OnPressed += e => this.IsOpen = !this.IsOpen;
|
this.OnPressed += e => {
|
||||||
|
this.IsOpen = !this.IsOpen;
|
||||||
|
// close other dropdowns in the same root when we open
|
||||||
|
if (this.IsOpen) {
|
||||||
|
this.Root.Element.AndChildren(o => {
|
||||||
|
if (o != this && o is Dropdown d && d.IsOpen)
|
||||||
|
d.IsOpen = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
this.GetGamepadNextElement = (dir, usualNext) => {
|
this.GetGamepadNextElement = (dir, usualNext) => {
|
||||||
// Force navigate down to our first child if we're open
|
// Force navigate down to our first child if we're open
|
||||||
if (this.IsOpen && dir == Direction2.Down)
|
if (this.IsOpen && dir == Direction2.Down)
|
||||||
|
|
Loading…
Reference in a new issue