Re: Styling the selected Tab's label in TabView
- To: mathgroup at smc.vnet.net
- Subject: [mg98289] Re: Styling the selected Tab's label in TabView
- From: John Fultz <jfultz at wolfram.com>
- Date: Sun, 5 Apr 2009 06:36:00 -0400 (EDT)
- Reply-to: jfultz at wolfram.com
The only reason for the Graphics[] in the example you started with is because
that example requires the use of Disk[]/Circle[] to produce the intended effect.
You don't need a Graphics[] wrapper in your case, and removing it makes your
code more comprehensible and as well as making it work as I believe you
intended.
DynamicModule[{selected},
TabView[Table[
With[{i = i},
Style[labels[[i]],
FontWeight ->
Dynamic[If[i === selected, Bold, Plain]]] -> ("Hello " <>
labels[[i]] <> "!")], {i, Length[labels]}], Dynamic[selected]]]
Sincerely,
John Fultz
jfultz at wolfram.com
User Interface Group
Wolfram Research, Inc.
On Fri, 3 Apr 2009 04:35:58 -0500 (EST), Bryce Schober wrote:
> It seems that you can't set the LabelStyle of individual tabs in a
> TabView.
>
> Starting with the example in my TabView->Examples->Scope->Control
> documentation, I got to:
>
> labels = {"Bill", "Susan"};
> DynamicModule[
> {selected},
> TabView[
> Table[
> With[
> {i = i},
> Graphics[
> Style[
> Text[labels[[i]]],
> FontWeight -> Dynamic[
> If[i === selected,
> Bold,
> Plain
> ]
> ]
> ],
> ImageSize -> All,
> PlotRangePadding -> .5
> ] -> ("Hello " <> labels[[i]] <> "!")
> ],
> {i, Length[labels]}
> ],
> Dynamic[selected]
> ]
> ]
>
> This manages to bold the selected tab, but ImageSize -> All isn't=
limiting
> itself to the size of the Text[], and I'm not sure how to limit the
> resulting tab size to only that required for the text display...