I'm trying to make a wrapper for ListPicker
that delays updating the list unless Ctrl or Shift is released. The aim is to allow nested ListPickers
to work without grinding to a halt.
I've made some headway using an answer by @István Zachar to a question on detecting key release: Detecting KeyUp events
The ListPicker2
code snippet below generates a new list that updates when I release either Ctrl or Shift, just as I would like.
However, I'd like it to to update x
only when Ctrl or Shift are released, not just the new list (that way ListPicker2 can become a direct replacement for ListPicker in my scripts).
I'm missing something, hopefully it is a simple! How do I make x
in the script below only update this way?
ListPicker2[tempX_, list_] := DynamicModule[{return, shiftDown},
Print[ListPicker[Dynamic[tempX], list]];
shiftDown = False;
Dynamic[If[
MemberQ[CurrentValue["ModifierKeys"], ("Shift" | "Control")],
(shiftDown = True;),
If[shiftDown,
(shiftDown = False; return := tempX)];
];
Dynamic[return, TrackedSymbols :> {return}]
]
]
x =.;
ListPicker2[x, {a, b, c, d}]
Dynamic[x]
ListPicker
, you can select multiple elements. That is why I'm not sure what do you want at the end. What if someone did not press any additional key at all? p.s.Print
is not the best approach, now I've gotListPicker
in message window ;) $\endgroup$