Re: CurrentValue
- To: mathgroup at smc.vnet.net
- Subject: [mg88720] Re: [mg88709] CurrentValue
- From: John Fultz <jfultz at wolfram.com>
- Date: Wed, 14 May 2008 06:04:27 -0400 (EDT)
- Reply-to: jfultz at wolfram.com
On Tue, 13 May 2008 07:10:54 -0400 (EDT), Hannes Kessler wrote:
> Hello,
>
> CurrentValue["SelectionData"] works for selections in the evaluation
> notebook:
>
> Button["label",
> With[{repeated = ToString@CurrentValue@"SelectionData"},
> NotebookApply[EvaluationNotebook[],
> "f[" <> repeated <> "," <> repeated <> "]"]]]
>
> How to use CurrentValue for other notebooks than the evaluation
> notebook?
> CurrentValue[NotebookSelection[nb]] does not work.
>
> Regards,
> Hannes Kesler
For a palette, you would do it like this...
CreatePalette@
Button["label",
With[{repeated =
ToString[CurrentValue[InputNotebook[], "SelectionData"]]},
NotebookApply[InputNotebook[],
"f[" <> repeated <> "," <> repeated <> "]"]]]
You can't use InputNotebook[] in a regular notebook because the
act of clicking on the button will make the notebook containing
the button the InputNotebook[]. Palettes don't have this property.
But, of course, it would work fine for any explicit NotebookObject[].
Sincerely,
John Fultz
jfultz at wolfram.com
User Interface Group
Wolfram Research, Inc.