4
$\begingroup$

I am trying to create a to-do list style for the stylesheet. The goal is to have a CellDingbat that is a check box. And after pressing enter, a new cell with a checkbox CellDingbat should be created, just like the style Item.

Initially, I posted the question in another thread, and with the help from @kglr I was able to create a to-do list style that has the desired behavior. Now, to make this to-do list style more practically useful, I would like the state of the Checkbox to be preserved after closing and re-opening the notebook. Can anyone suggest how to achieve this?

$\endgroup$
0

1 Answer 1

4
$\begingroup$

This addition to your style definition should do what you need:

TaggingRules -> {"done" -> True},
CellDingbat ->  Cell[BoxData[ CheckboxBox[
    Dynamic[CurrentValue[ ParentCell[EvaluationCell[]], {TaggingRules, "done"}]
]]]
$\endgroup$
5
  • $\begingroup$ Thanks! The only thing that I have changed is "done"->True to "done"->False, so that it the state of the Checkbox is False at the begining. $\endgroup$ Feb 2, 2021 at 19:34
  • $\begingroup$ By the way, @Kuba, I didnt find any definition of CheckboxBox in the Help center, where can I find the usage of this function? $\endgroup$ Feb 2, 2021 at 20:35
  • $\begingroup$ @bakerryd123 it is just a box representation of Checkbox, evaluate Checkbox[] and Ctrl+Shift+E on the output cell. See also reference.wolfram.com/language/tutorial/… . p.s. yes False makes sense ofc. $\endgroup$
    – Kuba
    Feb 3, 2021 at 5:34
  • 2
    $\begingroup$ @bakerryd123, I suggest you consider accepting this answer (as it is extremely unlikely that there will be a better answer) . Re accepting see the Tour page $\endgroup$
    – kglr
    Feb 3, 2021 at 17:59
  • 1
    $\begingroup$ Accepted, I didn't know this 'accepting thing' before. $\endgroup$ Feb 4, 2021 at 1:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.