1
$\begingroup$

I am trying to adapt the following snippet to behave in such a way that when a new selection is made - even if there is no change, then the date time stamp updates, I would also like to grab the user profile name from computer and append it to the date with every change. The purpose of which is to ascertain from which computer login was the selection made from.

(*user defined levels and associated colors*)
levels = {"Self Assess", "Mastery", "Dominance", "Proficeincy", 
   "Fuzzy"};
levelColors = {White, Green, Yellow, Red, Gray};

DynamicModule[{x = levels[[1]]},
 Row[{PopupMenu[Dynamic[x], levels,
    Background -> Dynamic[
      Which[
       x === levels[[1]], levelColors[[1]],
       x === levels[[2]], levelColors[[2]],
       x === levels[[3]], levelColors[[3]],
       True, levelColors[[4]]]]],
   DateString[]}]]

I tried Refresh, Dynamic@Row, TrackedValue, and even ValueFunction to no avail. Any Thoughts?

$\endgroup$
3
$\begingroup$

Not an expert (so you might want to wait for some more input from others), something like this works for me (assuming this is what you have in mind).

The idea is to use the second argument to Dynamic to update the date, which (here) is stored in t:

(*user defined levels and associated colors*)
levels = {"Self Assess", "Mastery", "Dominance", "Proficeincy", 
   "Fuzzy"};
levelColors = {White, Green, Yellow, Red, Gray};

DynamicModule[
 {x = levels[[1]],
  t = DateString[]},
 Row[{
   PopupMenu[
    Dynamic[x, (x = #; t = DateString[]) &],
    levels,
    Background -> Dynamic[
      First@Pick[
        levelColors,
        levels,
        x
        ]
      ]
    ],
   Dynamic[t],
   SystemInformation["FrontEnd", "UserName"]
   },
  Spacer[5]
  ]
 ]
$\endgroup$
  • 1
    $\begingroup$ This is definitely usable. Thank you so much for your time. $\endgroup$ – Keith D Dec 4 '17 at 21:50
  • $\begingroup$ No problem, glad it ended up being helpful! $\endgroup$ – Anne Dec 4 '17 at 21:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.