Request 1: A workaround for Cells
or NotebookFind
needs to be found for locating and returning the CellObject
-s of DockedCells
with identifying cell properties like CellID
or CellTags
. Someone out there knows what to do. If you know of a way no matter how hackey please help.
Request 2: If you believe this is a bug with Cells
or NotebookFind
or should be considered one or is missing expected functionality, please alert me and I will happily submit a bug report or a request for feature enhancement to the Wolf
For plenitude I am coding a DockedCells
toolbar remover which defaults to the nuclear option (removes all docked) but can selectively only remove single docked when given an identifying property such as CellTags
or CellID
. The code is irrelevant but given in case you need it to clean up after testing your solutions to this.`
ClearAll[RemoveDocked]
RemoveDocked[spec_ : "Nuclear", prop_ : CellTags] := Module[{},
(* nucLear option removes all docked *)
If[(MatchQ[spec, All] ||
StringMatchQ[spec, "nuclear" | "nuke",
IgnoreCase -> True]), (SetOptions[EvaluationNotebook[],
DockedCells -> Inherited]; Return[])];
(* here is where code for removing individual docked would be placed *)
Echo[spec, "spec \[RightTeeArrow]"];
];
Below are the sample DockedCells
toolbars I coded to test my CellObject
locators, which by the way work fine on Input
cells but return empty list {}
for Cells
and $Failed
forNotebookFind
.
ClearAll[ops, bops, txt, but, nuk]
ops = Sequence[FontSize -> 16, FontColor -> White,
FontFamily -> "Courier New", Background -> Darker@Darker@Blue,
CellFrameMargins -> 7, ShowCellTags -> False];
bops[col_ : Black, bg_ : None] :=
Sequence[BaseStyle -> {12, col, Bold}, Background -> bg];
txt = Cell[
"This is only plain text. No boxes were harmed in making this.",
"DockedCell", ops, CellID -> 111, CellTags -> "txt"];
but = Cell[
BoxData[ToBoxes[
Row[{"Manually save your work or turn on autosave. ",
Button["NB Save", NotebookSave[], bops[]], " ",
Button["NB AutoSave",
SetOptions[EvaluationNotebook[], NotebookAutoSave -> True],
bops[]]}]]], ops, CellID -> 222, CellTags -> "but"];
nuk =
Cell[BoxData[
ToBoxes[Row[{Style["Exercise Nuclear Option: ", Bold, Italic],
"the world will never be the same again. ",
Button["Unset All Docked", RemoveDocked["Nuclear"],
bops[White, Darker@Red]]}]]], ops, CellID -> 333,
CellTags -> "nuk"];
SetOptions[EvaluationNotebook[], DockedCells -> {txt, but, nuk}]
Below are my tests for finding DockedCells
(first three in lists) with Cells
and NotebookFind
. I used Input
cells (last three in lists) as my experimental controls.
(* DockedCells return an enpty List {} or $Failed *)
(* Input Cells (last 3 in tags and ids) return a CellObject *)
ClearAll[tags, ids]
tags = {"txt", "but", "nuk", "cases1", "cases2", "del"};
ids = {111, 222, 333, 100, 200, 321};
(* with Cells *)
Echo[Cells[CellTags -> #] & /@ tags, "Cells by CellTags \[Rule] "];
Echo[Cells[CellID -> #] & /@ ids, "Cells by CellID \[Rule] "];
(* with NotebookFind *)
Echo[NotebookFind[EvaluationNotebook[], #, All, CellTags,
IgnoreCase -> True, WrapAround -> True] & /@ tags,
"NotebookFind by CellTags \[Rule] "];
Echo[NotebookFind[EvaluationNotebook[], #, All, CellID,
IgnoreCase -> True, WrapAround -> True] & /@ ids,
"NotebookFind by CellID \[Rule] "];
DockedCells
also via the correspondingCellObject
s, what can be more convenient in some cases. It is sad that there is no simple way to get theseCellObject
s. I hope it will be added in the future. $\endgroup$DockedCells
option toCells
was considered whenAttachedCells
was added. I wouldn't hold out hope for it. @Jules Manson, removing a particularCell
from theDockedCells
it is just a matter of list manipulation. Assuming it was programmatically added to the notebook in the first place. $\endgroup$CellObject
all you want. Whatever you do will never be reflected back into the option though, which is simply a consequence of the design. $\endgroup$EvaluationCell[]
is the only robust way to do it. Otherwise, you are creating something that depends on initial preconditions. $\endgroup$