Skip to content

Commit

Permalink
Explicitly return the element type from Dropdown.AddElement overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellpeck committed Dec 17, 2024
1 parent 866aec8 commit 5fa0530
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ Additions
- Added the ability for Dropdown to display an arrow texture based on its open state
- Added the ability to specify Dropdown paragraph colors through style properties

Improvements
- Explicitly return the element type from Dropdown.AddElement overloads

Fixes
- Fixed tooltips not being bounded correctly for viewports that don't start at the origin
- Fixed a stack overflow exception when a panel's children have just enough height to cause a scroll bar to appear
Expand Down
7 changes: 4 additions & 3 deletions MLEM.Ui/Elements/Dropdown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public Dropdown(Anchor anchor, Vector2 size, Paragraph.TextCallback textCallback
/// </summary>
/// <param name="element">The element to add</param>
/// <param name="index">The index to add the child at, or -1 to add it to the end of the <see cref="Element.Children"/> list</param>
public void AddElement(Element element, int index = -1) {
public Element AddElement(Element element, int index = -1) {
this.Panel.AddChild(element, index);
// Since the dropdown causes elements to be over each other,
// usual gamepad code doesn't apply
Expand All @@ -142,6 +142,7 @@ public void AddElement(Element element, int index = -1) {
}
return usualNext;
};
return element;
}

/// <summary>
Expand All @@ -150,7 +151,7 @@ public void AddElement(Element element, int index = -1) {
/// <param name="text">The text to display</param>
/// <param name="pressed">The resulting paragraph's <see cref="Element.OnPressed"/> event</param>
/// <param name="index">The index to add the child at, or -1 to add it to the end of the <see cref="Element.Children"/> list</param>
public Element AddElement(string text, GenericCallback pressed = null, int index = -1) {
public Paragraph AddElement(string text, GenericCallback pressed = null, int index = -1) {
return this.AddElement(p => text, pressed, index);
}

Expand All @@ -161,7 +162,7 @@ public Element AddElement(string text, GenericCallback pressed = null, int index
/// <param name="text">The text to display</param>
/// <param name="pressed">The resulting paragraph's <see cref="Element.OnPressed"/> event</param>
/// <param name="index">The index to add the child at, or -1 to add it to the end of the <see cref="Element.Children"/> list</param>
public Element AddElement(Paragraph.TextCallback text, GenericCallback pressed = null, int index = -1) {
public Paragraph AddElement(Paragraph.TextCallback text, GenericCallback pressed = null, int index = -1) {
var paragraph = new Paragraph(Anchor.AutoLeft, 1, text) {
CanBeMoused = true,
CanBeSelected = true,
Expand Down

0 comments on commit 5fa0530

Please sign in to comment.