dynamic - Using a setterbar to set text alignment while keeping the current vertical cursor bar position
The code below generates a SetterBar that dynamically updates with the current text justification (where the vertical cursor bar is located) and allows you to change it to a new justification. See gif below.
SetterBar[
Dynamic[e =
CurrentValue[NotebookSelection[],
TextAlignment], {SelectionMove[InputNotebook[], All, Cell];
SetOptions[NotebookSelection[InputNotebook[]],
TextAlignment -> #]} &], {Left, Center, Right}]
The code contains the function SelectionMove[InputNotebook[], All, Cell]
. The problem with keeping that function in the code is that I lose the current vertical curser bar position. See gif below.
I would like to keep the current cursor bar position where its at, but if remove that function the setter bar doesn't work anymore. Do you have any ideas?
Comments
Post a Comment