Fabrice Couvreur mailto:fabrice1.couvreur@gmail.com 26. Juli 2016 um 20:21 Hi Hans, I think I was not very clear.
Title first framed : Hans
Title second framed : Hagen
You can pass a title to the optional framedtext argument (use camel case to avoid using existing key names) and access the value later in the metapost graphic.
Thanks Fabrice
\setupbodyfont[pagella,11pt]
\setupcolors[state=start]
\defineframedtext [MyFrame] [before={\blank}, after={\blank}, frame=off, background=MyFrame, width=\textwidth, width=max, height=fit, style=italic]
\setvariables [text] [text1=Hans, text2=Hagen,]
\startuseMPgraphic{MyFrame} path b; picture p; p := textext.rt("\white\getvariable{text}{text1}");
p := textext.rt("\white\framedtextparameter{Title}");
p := p shifted (2BodyFontSize,OverlayHeight-ypart center p+.25ExHeight); b := boundingbox p leftenlarged .5EmWidth rightenlarged .5EmWidth; fill OverlayBox withcolor lightgray; fill b withcolor darkred; draw bottomboundary OverlayBox withpen pencircle scaled 1pt withcolor darkred; draw topboundary OverlayBox withpen pencircle scaled 1pt withcolor darkred; draw p; setbounds currentpicture to boundingbox currentpicture enlarged 2mm; \stopuseMPgraphic
\defineoverlay [MyFrame] [\useMPgraphic{MyFrame}]
\starttext
\startMyFrame \input knuth \stopMyFrame
\startMyFrame \input knuth \stopMyFrame
\startMyFrame[Title=Hans] \input knuth \stopMyFrame \startMyFrame[Title=Hagen] \input knuth \stopMyFrame Wolfgang