ui/winui/button.cpp

branch
newapi
changeset 374
eae5d6623fd3
parent 373
2eede3d98aba
--- a/ui/winui/button.cpp	Wed Oct 30 11:07:52 2024 +0100
+++ b/ui/winui/button.cpp	Wed Oct 30 12:23:52 2024 +0100
@@ -56,12 +56,17 @@
 		icon = NULL;
 	}
 
-	if (label && icon) {
+	IconElement icon_elm = { nullptr };
+	if (icon) {
+		icon_elm = ui_get_icon(icon);
+	}
+
+	if (label && icon_elm) {
 		StackPanel panel = StackPanel();
 		panel.Orientation(Orientation::Horizontal);
 		panel.Spacing(5);
 		
-		panel.Children().Append(ui_get_icon(icon));
+		panel.Children().Append(icon_elm);
 
 		wchar_t* wlabel = str2wstr(label, nullptr);
 		TextBlock label = TextBlock();
@@ -76,7 +81,7 @@
 		button.Content(box_value(wlabel));
 		free(wlabel);
 	}
-	else if (icon) {
+	else if (icon_elm) {
 		button.Content(ui_get_icon(icon));
 	}
 }

mercurial