I created the following code that overlays an attached cell containing a large canvas on top of a notebook. This allows me to use the drawing tools on top of my notebook so that I can annotate code with my handwriting.
CreateWindow[DocumentNotebook[CellGroup[{
"Testing Writing Canvas Overlay",
"Step 1. Click Draw Above",
"Step 2. Invoke the locked freehand line drawing tool by pressing the f key twice.", "Step 3. Draw Something",
"Step 4. Click Reset to Delete AttachCell"}],
CellGrouping -> Manual,
WholeCellGroupOpener -> True],
DockedCells -> Cell[BoxData@ToBoxes@Row[{Button["Draw",
SelectionMove[ButtonNotebook[], Before, Notebook];
SelectionMove[ButtonNotebook[], Next, Cell];
obj =
AttachCell[SelectedCells[][[1]],
Style[Graphics[{}, AspectRatio -> Full,
ImageSize ->
AbsoluteCurrentValue[EvaluationNotebook[],
WindowSize]*{2, 2}], Deployed -> False,
Editable -> True], Left, 75, Left];
SelectionMove[obj, All, CellContents]],
Button["Reset",
NotebookDelete[
Cells[EvaluationNotebook[], AttachedCell -> True]]]}]]]
I would like to skip step 2 (as shown in the notebook). In other words, I would like to include an extra line of code that allows me to draw immediately upon pressing the "Draw" button. I don't want to have to press the f key at all.
It seems like I need to either simulate two keypresses of the f key somehow or invoke some frontendtoken twice to start the locked freehand line tool. Any ideas?