2

I'm editing a very long text in a Mathematica notebook and I'm using the "Article" stylesheet. In this text, code is highlighted using

Style[codeToHighlight, FontFamily -> "Arial", FontSlant -> Italic]

or Format -> Font -> ... after selecting it.

I want to define a "Ctrl + 0" keyboard shortcut to make selected a portion of text cell appear in Arial + Italic Style.

I'm re-reading this post and trying to make sense of what should I put into MenuSetup.tr, but I'm not sure if it's the right approach.

andandandand
  • 2,393
  • 1
  • 15
  • 16
  • 1
    I think this could help. Please refer to the following bit of documentation https://reference.wolfram.com/language/ref/EventHandler.html – e.doroskevic Nov 17 '15 at 17:18
  • 1
    To be able to easy change the procedure I'm recommending using joker functionality from Shortcuts` package: 34159 – Kuba Nov 17 '15 at 21:37

1 Answers1

0

Example:

DynamicModule[
 {font = "Courier"},
 EventHandler[
  Style["Text", FontFamily -> Dynamic[font]],
  {"KeyDown", 
    "x"} :> (font = 
     font /. {"Times" -> "Courier", "Courier" -> "Times"})]
 ]

On press of button x text "Text"toggles between font "Times" and "Courier"

e.doroskevic
  • 5,959
  • 1
  • 13
  • 32