summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Mittendrein <maxmitti@maxmitti.tk>2022-04-13 20:48:44 +0200
committerMarkus Mittendrein <maxmitti@maxmitti.tk>2022-04-13 20:48:44 +0200
commit5b02d0e21b03556c7ae6ee9b493a73fbd883dbb1 (patch)
tree56b76c51b94e00da2da39b5a8d4f6caa4e731983
parent3ba9430edb4036cfad8737f54f4eb8a844e7360b (diff)
downloadDTMenu.c4d-master.tar.gz
DTMenu.c4d-master.zip
Add Id field to Menu_Entry for consistent identification of entries across refreshesHEADmaster
-rw-r--r--Script.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/Script.c b/Script.c
index e9b791e..82a1905 100644
--- a/Script.c
+++ b/Script.c
@@ -1089,6 +1089,8 @@ func Refresh(array selection, bool delayed)
var oldNoSelectionCallbacks = noSelectionCallbacks;
noSelectionCallbacks = true;
+ var oldSelectionId = columnEntries[selection[1]]?[selection[0]]?.Id;
+
CloseMenu(settings.Object);
var oldRefreshing = refreshing;
@@ -1100,6 +1102,20 @@ func Refresh(array selection, bool delayed)
if(GetLength(columnEntries[column]) > 0)
{
+ if (oldSelectionId != nil)
+ {
+ var i = 0;
+ for (var entry in columnEntries[column])
+ {
+ if (entry.Id == oldSelectionId)
+ {
+ selection = i;
+ break;
+ }
+ ++i;
+ }
+ }
+
SelectEntry(BoundBy(selection, 0, GetLength(columnEntries[column]) - 1), column);
if(settings.InstantDescription.Enable)
@@ -1184,6 +1200,7 @@ Menu_Entry({
Callback = <Callback>,
AllowDisabledSelection = >Menu_Condition_Default< | Menu_Condition_AllowSelection | Menu_Condition_DenySelection
},
+ Id = <Can be set to any unique non-nil value to re-identify entries on refreshing/reopening>
Extra = <Same as extra of AddMenuItem> >Also used internally<,
XPar1 = <Same as XPar1 of AddMenuItem> >Also used internally<,
XPar2 = <Same as XPar2 of AddMenuItem> >Also used internally<,