Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6755551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:24:59+00:00 2026-05-26T13:24:59+00:00

I have modified my notebook’s stylesheet to include a StyleData[Todo] that inherits from StyleData[Item]

  • 0

I have modified my notebook’s stylesheet to include a StyleData["Todo"] that inherits from StyleData["Item"]. It changes the cell dingbat to a checkbox. In the stylesheet editor:

Cell[StyleData["ToDo", StyleDefinitions -> StyleData["Item"]], 
  CellDingbat->DynamicModuleBox[{$CellContext`color$$}, 
    CheckboxBox[
    Dynamic[$CellContext`color$$], {RGBColor[1, 0.5, 0],RGBColor[0,Rational[2, 3], 0]},    
    Background -> Dynamic[$CellContext`color$$]], 
    DynamicModuleValues :> {}
  ],
]

The problem is that the state of the checkbox, when used in a notebook, is not saved between Mathematica sessions. I thought the DynamicModule[] would do the trick. How do I get the checkbox to remember its state?

EDIT

Simon’s solution does save the state of the checkbox, but the checkbox is clipped when used as a CellDingbat (MacOS X). Putting Simon’s code in a CellFrameLabels options does the trick, and also keeps the default “Item” CellDingbat. Here is what I’ve gone with:

Cell[StyleData["ToDo", StyleDefinitions -> StyleData["Item"]],
 CellFrameLabels->{{
    ButtonBox[
     CheckboxBox[False], ButtonFunction :> (SelectionMove[
        ButtonNotebook[], All, ButtonCell]; 
      With[{$CellContext`new = ReplaceAll[
           Options[
            NotebookSelection[
             ButtonNotebook[]], CellFrameLabels], CheckboxBox[
             Pattern[$CellContext`x, 
              Alternatives[True, False]]] :> CheckboxBox[
             Not[$CellContext`x]]]}, 
        SetOptions[
         NotebookSelection[
          ButtonNotebook[]], $CellContext`new]]; SelectionMove[
        ButtonNotebook[], After, CellContents]), Appearance -> None, 
     Method -> "Preemptive", Evaluator -> Automatic], None}, {
   None, None}},
 MenuSortingValue->1621]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:25:00+00:00Added an answer on May 26, 2026 at 1:25 pm

    The problem with your code (I think) is that a new DynamicModule does not get created each time you create a new “ToDo” cell. So there is nowhere that the state of each Checkbox can get saved.

    The simplest solution I could think of for storing the state of the Checkbox for each “ToDo” cell is to overwrite the CellDingbat the first time that the Checkbox is activated.
    (Other options I played with were using TaggingRules,
    toggling between “ToDo” and “ToDone” styles, etc…)

    However, even a plain Checkbox in a CellDingbat does not store its state – try running the following then cycle the output through a Show Expression cycle.

    CellPrint[Cell["test", "Text", CellDingbat -> ToBoxes[Checkbox[]]]]
    

    To get around this, I used Checkbox with the definite argument True or False wrapped up in a button that changes the state. This is stupid and inefficient, but it works!

    So, my code for the cell style

    Cell[StyleData["ToDo", StyleDefinitions -> StyleData["Item"]],
     CellDingbat -> ButtonBox[CheckboxBox[False], 
       ButtonFunction :> (SelectionMove[ButtonNotebook[], All, ButtonCell]; 
         With[{$CellContext`new = ReplaceAll[
              Options[NotebookSelection[ButtonNotebook[]], CellDingbat], 
              CheckboxBox[Pattern[$CellContext`x, Alternatives[True, False]]] :> CheckboxBox[Not[$CellContext`x]]]}, 
            SetOptions[NotebookSelection[ButtonNotebook[]], $CellContext`new]]; 
          SelectionMove[ButtonNotebook[], After, CellContents]), 
        Appearance -> None, Method -> "Preemptive", Evaluator -> Automatic]]
    

    Screenshota

    I’m not happy with this solution, but it’s the best I’ve come up with. An improvement would be to move the button function code out of the cell so that it is not repeated for every checked ToDo cell. Also to make it run without a ReplaceAll so that the kernel is not needed and the function can be run using just the frontend.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have modified a 'BUG' work item template to include an initial state of
I have modified the Android Bluetooth Chat code so that bytes received from the
I have modified a working Windows service that had always been starting beforehand. After
I have a dataset that I have modified into an xml document and then
I have modified my etc/hosts file (under Windows 7), so that www.example.com and demo.example.com
I have modified my application, so that when a new user is registered, it's
I have modified a UISegmentedControl so that it is vertical instead of horizontal- it
i have a script that i have modified to meet my requirements however i
I have modified the guestbook example shipped with google app engine (java) to include
It seems to have modified the original string that I wanted to split specifying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.