I use pgfkeys
to hold specific values (text). Now I'd be able to limit the possible values of that key (only some values valid). How is this possible with pgfkeys
? (I saw .is choice
but don't know how to use this to limit key values since its primarily use is for the .code
or .style
handler)
1 Answer
Perhaps you can define the key as
\pgfkeys{
mykey/.is choice,
mykey/value1/.code={\def\mykey@value{#1}},
mykey/value2/.code={\def\mykey@value{#1}},
% more allowed values
}
and use \mykey@value
to retrieve the value passed to mykey
, like \pgfkeysvalueof{mykey}
if it is defined by \pgfkeys{mykey/.initial}
.
\pgfkeys(getvalue|valueof)
with that key while have the ability to only accept selected values? I mean, alternatively, you can use sth like\pgfkeys{mykey/.is choice, mykey/value1/.code={\def\store@value{value1}}}
.\def
is local to the current group,\gdef
is global.