5
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ After your update it is unclear what your question is. Can "what" be done in the front end only? $\endgroup$ – Mike Honeychurch Oct 18 '13 at 20:42
  • $\begingroup$ @MikeHoneychurch: I re-worded the question, thank you for the note. $\endgroup$ – Hector Oct 18 '13 at 22:12
3
$\begingroup$

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?

$\endgroup$

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.