It seems there is something wrong in the expected behaviour of setting an option back to its default value when this command is executed inside a *EventActions
: the default (Inherited
) value does not correspond to the next (up) level value it should.
Here is a simple example with the Background
color option.
Without *EventActions
all work as it should:
1/ Start a fresh session and create a new working notebook to input the following commands.
2/ Define a default background color for the session
SetOptions[$FrontEndSession, Background -> Yellow]
(* OK: the background is now yellow *)
3/ Modify the notebook private background color:
SetOptions[EvaluationNotebook[], Background -> LightBlue]
(* OK: the background is now LightBlue*)
4/ Revert to the default background color:
SetOptions[EvaluationNotebook[], Background -> Inherited]
(* OK: the inherited background color is now yellow -> $FrontEndSession one *)
Problem with *EventActions
:
5/ Let's say now you need to automatically revert to the default background color when you press a given key:
First let's turn it blue again:
SetOptions[EvaluationNotebook[], Background -> LightBlue]
then
SetOptions[EvaluationNotebook[],
NotebookEventActions -> {{"KeyDown", "b"} :> (SetOptions[EvaluationNotebook[],
Background -> Inherited])}]
and now type "b" in the notebook ...
Instead of yellow, the background color is "white" (as the hard-coded default one), it has been set to
CurrentValue[EvaluationNotebook[], Background]
None
So, what is wrong or what am i doing wrong here ?
Concerning Inherited
behaviour, wouldn't it be better if it worked like Automatic
, that means it is never automatically replaced by some absolute value when displayed in options settings ?