Message Boards Message Boards

How are EvaluationNotebook and ButtonNotebook different?

GROUPS:
I have already asked this question on the Mathematica StackExchange (but haven't received a satsfactory asnwer), so please see there as well.

Is there a situation where EvaluationNotebook[] and ButtonNotebook[] would return different results when called in the same context (other than when ButtonNotebook[] returns $Failed because it was not run from a button)?  The documentation states:
If a button in a palette initiates evaluation in another notebook, then ButtonNotebook[] will be the palette, but EvaluationNotebook[] will be the other notebook. 
So in other words, the question is: how can a palette button initiate an evaluation in another notebook?  Here's a small test example:
CreatePalette[Button["press", Print@{EvaluationNotebook[], ButtonNotebook[]}]]
Notice that both return the palette, even if the focus is in another notebook (SelectedNotebook[] or InputNotebook[] would return that one). Is it possible to run Print@{EvaluationNotebook[], ButtonNotebook[]} in a context where they'd return different results? If not, then what is the purpose of ButtonNotebook[]?
POSTED BY: Szabolcs Horvát
Answer
5 years ago
They're identical.  ButtonNotebook was the original name and is kept around for legacy purposes, but EvaluationNotebook is a better name because the concept is appropriate for use in many places other than buttons.
POSTED BY: John Fultz
Answer
5 years ago

So the second statement under "Details" section of Documentation page for ButtonNotebook is wrong:

If a button in a palette initiates evaluation in another notebook, then ButtonNotebook[] will be the palette, but EvaluationNotebook[] will be the other notebook.

Shouldn't it be corrected then?

Expanded question.

POSTED BY: Alexey Popkov
Answer
5 months ago

Group Abstract Group Abstract