From 452a7df92a64a76c73d96468aa285fa87a7d5f0c Mon Sep 17 00:00:00 2001
From: giuliaghirardini <giulia.ghirardini@skywarder.eu>
Date: Sun, 6 Apr 2025 19:02:20 +0200
Subject: [PATCH] [fixes] Fixed a bug where the input was not being properly
 processed

---
 .../utilities/exportStandardizedFigure/fct/updatePreview.m | 2 +-
 .../mainExportStandardizedFigure.m                         | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/functions/utilities/exportStandardizedFigure/fct/updatePreview.m b/functions/utilities/exportStandardizedFigure/fct/updatePreview.m
index 1c3d919..8d10fd5 100644
--- a/functions/utilities/exportStandardizedFigure/fct/updatePreview.m
+++ b/functions/utilities/exportStandardizedFigure/fct/updatePreview.m
@@ -17,7 +17,7 @@ for i = 1:length(figHandles)
     width = pos(3);
     height = pos(4);
     leftOffsetNew = screen.width/5;
-    topOffsetNew = screen.weight/3;
+    topOffsetNew = screen.height/3;
 
     positionCurrentFig = [screen.width-width-leftOffsetNew, ...
         screen.height-height-topOffsetNew, width, height];
diff --git a/functions/utilities/exportStandardizedFigure/mainExportStandardizedFigure.m b/functions/utilities/exportStandardizedFigure/mainExportStandardizedFigure.m
index 1ab33a3..b010f7a 100644
--- a/functions/utilities/exportStandardizedFigure/mainExportStandardizedFigure.m
+++ b/functions/utilities/exportStandardizedFigure/mainExportStandardizedFigure.m
@@ -155,13 +155,16 @@ uilabel(fig, 'Text', 'Select Figure:', 'Position', [50, 500, 100, 30]);
 figSelectionDropDown = uidropdown(fig, ...
     'Items', figNames, ...
     'Position', [150, 500, 200, 30], ...
-    'Tooltip', 'Select the figure you want to export', ...
-    'ValueChangedFcn', @(src, event) updatePreview(fig, flagsPanel, screen, dropDown, box, inputFields));
+    'Tooltip', 'Select the figure you want to export');
 
 %%% save dropdown into a structure
 dropDown.prefixIPT = prefixIPTNameDropDown;
 dropDown.figSelection = figSelectionDropDown;
 
+% Set the callback *after* dropDown is complete
+figSelectionDropDown.ValueChangedFcn = @(src, event) updatePreview(fig, ...
+    flagsPanel, screen, dropDown, box, inputFields);
+
 % Automatically update preview if only one figure exists
 if isscalar(figHandles)
     saveTemporaryFigure(fig);
-- 
GitLab