5

I know FrontEnd`SelectionSetStyle is undocumented, but its name suggests it does what I need. What is its syntax?

I have already tried several variations of the following button on some selected code in an input cell.

Button["set", 
  FrontEnd`SelectionSetStyle[FontColor, RGBColor[{1, 0, 0}]];
  Print[CurrentValue["SelectionData"]]]

Update

Using the kernel, the following code does what I need:

Button["set", 
 SetOptions[NotebookSelection[InputNotebook[]], FontColor -> RGBColor[{0, .7, .5}]]; 
 Print[CurrentValue["SelectionData"]]]

I assume that FrontEnd`SelectionSetStyle can change the font color of the selection while using the front end only. If so, what is its syntax?

Hector
  • 6,428
  • 15
  • 34

1 Answers1

3

Your assumptions are most probably wrong, it seems that this function is meant to change CellStyle.

e.g. use this code to convert Input cells to Title cells in current notebook:

(
 SelectionMove[#, All, Cell];
 MathLink`CallFrontEnd[FrontEnd`SelectionSetStyle[#, "Title"]]
   ) & /@ Cells[CellStyle -> "Input"]

Used here: Set the style of a cell (link corrected)

Found there: How can I get the style of a CellObject?

Kuba
  • 136,707
  • 13
  • 279
  • 740