Reputation: 25703
How can I detect if a front end token is available to execute? Alternately, how can I detect if a front end token failed to execute?
Example: the Edit -> Copy command is not available if nothing is selected. FrontEndTokenExecute["Copy"]
will simply beep in this case, but it gives me no (programmatic) indication that it has failed.
Upvotes: 9
Views: 246
Reputation: 16232
I found a method to deal with your second question, but it's not elegant:
Preferences > Interface > Message and Warning actions
set Minor user interface warnings to Beep and Print to Console Notebooks[]
or so)NotebookGet[NotebookObject[FrontEndObject[LinkObject["55d_shm", 1, 1]], 1]]/. Notebook[{___, Cell[a___]}, ___] :> Cell[a]
(your handle will look differently, of course)Cell["You tried to edit a cell that is not editable. You can make the \
cell editable by choosing Cell Editable in the Cell Properties \
submenu.", "Message", "Message", "MSG", PageWidth -> WindowWidth,
ShowCellLabel -> True, CellChangeTimes -> {3.534442831*10^9},
CellTags -> "cantEditLockedCell"]
Upvotes: 5