Message Boards Message Boards

1
|
4556 Views
|
1 Reply
|
2 Total Likes
View groups...
Share
Share this post:

Use SetCellGroupOpen with Dynamic

Posted 6 years ago

The new inline cell openers work via a packet called FEPrivate`SetCellGroupOpen. The usage for this is something like:

MathLink`CallFrontEnd@
 FrontEnd`Value@
  FEPrivate`SetCellGroupOpen[
   cell,
   Open|Close|True|False
   ] 

Now I want to get this to work like the little orange clickers in the docs which have a Dynamic state in the second arg to their CellGroupData. Is there a way to make this function do that or any method that does not involve NotebookWrite/Put?

POSTED BY: b3m2a1 ​ 

I don't think it can as docs seem to work on higher level. (TaggingRules).

Also, this example DOES NOT work but is close. I assumed "ExampleSection" | "ExampleSubsection" have appropriate CounterIncrements but they do not. If you edit Reference.nb so they have, then you could use this code. Currently it works well only for "NotesSection" | "PrimaryExamplesSection" and the very first ExampleSection or ExampleSubsection as the counter is fixed at 0.

With[{cell = NextCell[] (*whatever you want*)}
, Module[{ spec, style = First @ Flatten @ {"Style" /. Developer`CellInformation[cell]} }
  , spec = Switch[style
    , "NotesSection" | "PrimaryExamplesSection", {TaggingRules, "Openers", style}
    , "ExampleSection" | "ExampleSubsection", {TaggingRules, "Openers", style, CurrentValue[cell, {"CounterValue", style}]}
    , _, False
    ]
  ; If[
      ListQ @ spec
    , CurrentValue[ParentNotebook@cell, spec] = CurrentValue[ParentNotebook@cell, spec] /. {
        False -> True, True -> False, Open -> Closed, Closed -> Open
      }
    ]
  ]
]
POSTED BY: Kuba Podkalicki
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract