Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

When I edit a slide show it easy to copy whole slides in Working Screen Environment but nice to preview slides in SlideShow Screen Environment.

enter image description here

Mathematica has convenient interactive buttons to go to Full Screen mode and change slides.

enter image description here

Is it possible to set up an easy button or hot key to switch between Working and SlideShow Screen Environments to avoid trips to menu? Maybe using DockedCells ? Any similar ideas ?

share|improve this question
    
Slideshow has its own DockedCell so while you could do as you suggested it would require you to create your own stylesheet that adds the switching buttons to your docked cell and preserves the existing slideshow DockedCell. –  Mike Honeychurch Jun 26 '12 at 7:01
    
@Vitaliy Kaurov, How do you get the broken egdes shown in your post?I'm fond of that. –  yulinlinyu Jun 27 '12 at 2:18
    
@yulinlinyu mathematica.stackexchange.com/questions/4148 –  Vitaliy Kaurov Jun 27 '12 at 2:57
    
@VitaliyKaurov, thank you very much. –  yulinlinyu Jun 27 '12 at 3:00
add comment

4 Answers 4

up vote 15 down vote accepted

You can use NotebookEventActions

SetOptions[EvaluationNotebook[], 
 NotebookEventActions :> {{"KeyDown", "s"} :> SetOptions[EvaluationNotebook[], 
     ScreenStyleEnvironment -> "SlideShow"], {"KeyDown", "w"} :> 
    SetOptions[EvaluationNotebook[], ScreenStyleEnvironment -> "Working"]}]

This is rudimentary so you can play around and choose your keys etc. but it seems to do what you want (it worked ok for me with 8.0.4 on OS X 10.6.8).

Note that NotebookEventActions can be set globally in the options inspector so you can paste:

{{"KeyDown", "s"} :> SetOptions[EvaluationNotebook[], 
         ScreenStyleEnvironment -> "SlideShow"], {"KeyDown", "w"} :> 
        SetOptions[EvaluationNotebook[], ScreenStyleEnvironment -> "Working"]}

into the options inspector. I just tried this and it works fine -- hopefully there are no unintended consequences so use at your own risk. :)

Edit

When I wrote this answer I chose "s" and "w" keys for "slideshow" and "working" just for example. Clearly it is not practical to tie up the "s" and "w" keys at the notebook level. However the next day I tried to make these event keys function keys and couldn't get it to work so contacted WRI tech support. They advise that there is no (documented) way to use the shift, option, control, and function keys with EventHandler. Further they said there is no way to use key combinations with EventHandler.

So therefore the stylesheet method that I posted the other day looks like the best way to (practically) achieve what you want.

share|improve this answer
    
This is better than my failed attempt even if it had worked. I was so locked into thinking about menu items I forgot to consider what was really going on. +1 ! –  Mr.Wizard Jun 26 '12 at 7:21
    
@Mr.Wizard Not sure how practical it is to tie up keys but seems to be what he is after(?) –  Mike Honeychurch Jun 26 '12 at 7:25
    
+1 @MikeHoneychurch Nice. Little impracticality - cannot type w and s - perhaps just fixed with using up F7, F8 keys instead. –  Vitaliy Kaurov Jun 26 '12 at 7:30
    
@VitaliyKaurov I just chose "s" and "w" for stylesheet and working by way of example. You can obviously choose whatever keys you prefer. –  Mike Honeychurch Jun 26 '12 at 7:40
    
@VitaliyKaurov please see edit re: function keys. –  Mike Honeychurch Jun 29 '12 at 23:38
show 2 more comments

You could edit the MenuSetup.tr file in the same manner as KeyEventTranslations.tr to include shortcut keys for each mode.


At present I cannot see a way to make this actually work. I am leaving the answer here for a while in case someone else can, and because I am curious to know what can be done with the "MenuListScreenStyleEnvironments" token.

share|improve this answer
    
+1 This is nice idea, thank you. I'd like to see also if someone will come up with button idea. –  Vitaliy Kaurov Jun 26 '12 at 6:05
    
@Vitaliy wait! I cannot find the menu items in MenuSetup.tr only a cryptic: MenuItem["Styles", "MenuListScreenStyleEnvironments", MenuAnchor->True] This method may not work. –  Mr.Wizard Jun 26 '12 at 6:06
    
Yes, it'd be good to check ;-) Maybe it'll still work out. –  Vitaliy Kaurov Jun 26 '12 at 6:08
    
@Vitaliy do you have any idea how to use these "MenuList..." items? There are a number of them in MenuSetup.tr and I don't know if it is possible to use these to drill down to find tokens for individual implicit sub-items. –  Mr.Wizard Jun 26 '12 at 6:21
1  
ActionMenu["ChangeEnvironment", RuleDelayed[#, SetOptions[EvaluationNotebook[], ScreenStyleEnvironment -> #2]] & @@@ FE`Evaluate[ FEPrivate`GetPopupList["MenuListScreenStyleEnvironments"]]] –  Kuba Mar 23 at 11:57
show 1 more comment

Here is a docked cell solution that can be added to a stylesheet:

Firstly make the docked cell grid. I'm using PaneSelector rather than If to choose how to layout the docked cell. An alternative is to create two separate docked cells, one for working and one for slideshow. This seems easier.

grid = DynamicModule[{slideshow = False},

  PaneSelector[{

    True -> Grid[{
       {Button[Graphics[{GrayLevel[0.3], Disk[]}, ImageSize -> 30],
         (FEPrivate`NotebookToggleFullScreen[]; {}),
         Appearance -> None],

        Style[Row[{

           Button["\[FirstPage]", 
            FrontEndTokenExecute[ButtonNotebook[], "ScrollPageFirst"],
             Appearance -> "Palette"], 
           Button["\[LeftPointer]", 
            FrontEndTokenExecute[ButtonNotebook[], 
             "ScrollPagePrevious"], Appearance -> "Palette"],

           Button["\[RightPointer]", 
            FrontEndTokenExecute[ButtonNotebook[], "ScrollPageNext"], 
            Appearance -> "Palette"], 
           Button["\[LastPage]", 
            FrontEndTokenExecute[ButtonNotebook[], "ScrollPageLast"], 
            Appearance -> "Palette"]}],
         DefaultOptions -> {
           Button -> {
             BaseStyle -> {FontSize -> 25, GrayLevel[0.3]},
             FrameMargins -> 0,
             ImageMargins -> 0,
             ImageSize -> 20}
           }
         ],

        DynamicModule[{cells = {}, tagFind = False},

         EventHandler[
          Dynamic[
           PopupMenu[Dynamic[0, With[{nb = ButtonNotebook[]},

               SelectionMove[nb, Before, Notebook, 
                AutoScroll -> False];
               If[tagFind,

                Do[NotebookFind[nb, "SlideShowHeader", Next, CellTags,
                   AutoScroll -> False], {#}], 
                Do[NotebookFind[nb, "SlideShowNavigationBar", Next, 
                  CellStyle, AutoScroll -> False], {#}]
                ];
               SelectionMove[nb, After, Cell, AutoScroll -> False];

               NotebookWrite[nb, 
                Cell["", Deletable -> True, ShowCellBracket -> False],
                 All];
               NotebookDelete[nb];

               SelectionMove[nb, If[tagFind, Previous, Next], 
                Cell]] &
             ], cells,
            Style[Row[{

               Dynamic[
                CurrentValue[{"CounterValue", 
                  "SlideShowNavigationBar"}]], 

               Dynamic[
                FrontEndResource["SlideshowToolbarText", 
                 "SlideshowToolbarCounterText"]], 
               Dynamic[
                CurrentValue[{"MaxCounterValue", 
                  "SlideShowNavigationBar"}]]
               }], "ControlStyle"],
            Appearance -> None,
            ImageSize -> Automatic]
           ],
          {"MouseDown" :> Module[{cnt, nb = InputNotebook[]},
             cells = {};

             cnt = Apply[(NotebookFind[nb, #1, All, #2, 
                  AutoScroll -> False]; 
                 CurrentValue[
                  nb, {"CellCount", 
                   True}]) &, {{"SlideShowNavigationBar", 
                 CellStyle}, {"SlideShowHeader", CellTags}}, {1}];
             cnt = (If[tagFind = #1 == 0, #2, #1] &) @@ cnt;

             SelectionMove[nb, Before, Notebook, 
              AutoScroll -> False];

             If[tagFind, 
              cells = (#1 -> "Slide " <> ToString[#1] &) /@ 
                Range[cnt], 
              Do[NotebookFind[nb, "SlideShowNavigationBar", Next, 
                CellStyle, AutoScroll -> False]; 
               SelectionMove[nb, Next, Cell, AutoScroll -> False]; 

               AppendTo[cells, 
                NotebookRead[nb] /. 
                 s_Style :> 
                  With[{ss = 
                    Join[Take[s, 1], 
                    DeleteCases[Rest[s], _String | _[FontColor, _]]]},
                    ss /; True]], {cnt}]; 
              cells = 
               Replace[
                cells[[All, 1]], {BoxData[c_] :> c, 
                 TextData[c_] :> Row[If[ListQ[c], c, {c}]]}, 1]; 
              cells = Thread[Range[cnt] -> cells]]]},
          PassEventsDown -> True,
          EvaluationOrder -> Before,
          PassEventsUp -> True]
         ],
        EventHandler[
         Pane[
          Style[Dynamic@
            If[TrueQ[slideshow], "Switch to Working", 
             "Switch to Slideshow"], FontFamily -> "Arial", 14], {150,
            30}, Alignment -> {Center, Center}],
         {"MouseClicked" :> If[TrueQ[slideshow],

            SetOptions[InputNotebook[], 
             ScreenStyleEnvironment -> "Working"]; 
            slideshow = ! slideshow,

            SetOptions[InputNotebook[], 
             ScreenStyleEnvironment -> "SlideShow"]; 
            slideshow = ! slideshow]}]
        }},
      AutoDelete -> False,
      Alignment -> {{Left, Center, Right}, Center},
      ItemSize -> {Automatic, Fit, Automatic},
      Spacings -> 3],

    False -> Grid[{
       {Button[Graphics[{GrayLevel[0.3], Disk[]}, ImageSize -> 30],
         (FEPrivate`NotebookToggleFullScreen[]; {}),
         Appearance -> None],

        EventHandler[
         Pane[
          Style[Dynamic@
            If[TrueQ[slideshow], "Switch to Working", 
             "Switch to Slideshow"], FontFamily -> "Arial", 14], {150,
            30}, Alignment -> {Center, Center}],
         {"MouseClicked" :> If[TrueQ[slideshow],

            SetOptions[InputNotebook[], 
             ScreenStyleEnvironment -> "Working"]; 
            slideshow = ! slideshow,

            SetOptions[InputNotebook[], 
             ScreenStyleEnvironment -> "SlideShow"]; 
            slideshow = ! slideshow]}]
        }},
      AutoDelete -> False,
      Alignment -> {{Left, Center, Right}, Center},
      ItemSize -> {Automatic, Fit, Automatic},
      Spacings -> 3]
    },
   Dynamic[slideshow]]
  ]

To add this as a docked cell:

SetOptions[EvaluationNotebook[], DockedCells -> {First[ToBoxes[
     TextCell[grid, Background -> GrayLevel[0.8], CellMargins -> 0]
     ]]}]

To remove it:

SetOptions[EvaluationNotebook[], DockedCells -> {}]

Notes:

  1. This has been cobbled together after studying how other slideshow docked cells work. Note the red EvalutionOrder option to EventHandler.

  2. This places the option (button, i.e. the disk on the left)) to go full screen from the working environment.

  3. You can switch between slideshow and working via the docked cell by clicking on "Switch to Working" and "Switch to Slideshow".

To make the stylesheet:

CreateDocument@Notebook[{
   Cell[StyleData[StyleDefinitions -> "Default.nb"]],
   Cell[StyleData["Notebook"],
    DockedCells -> {First[ToBoxes[
        TextCell[grid, Background -> GrayLevel[0.8], 
         CellMargins -> 0]
        ]]}]}, StyleDefinitions -> "PrivateStylesheetFormatting.nb"]

From there give it a name and install it.

share|improve this answer
    
Mike, thanks for this work, I really like the idea. Your button DockedCell completely removes slide show's default DockedCell - that's not suppose to happen right? –  Vitaliy Kaurov Jul 1 '12 at 3:23
    
Yes I have deliberately removed the default docked cell. I wanted one docked cell for both environments. You don't need the slideshow forward and back, first & last controls for working environment. I'll leave it up to you to make two different docked calls. To keep the existing one for slideshow you will need to overlay it with the switching button and make that layer active. –  Mike Honeychurch Jul 1 '12 at 4:01
    
+1 I see, thank you, great solution. –  Vitaliy Kaurov Jul 1 '12 at 4:02
add comment

For something really straightforward, could you not just use the built-in Slide Show palette? It has a View Environment button that allows you to select Slide Show, Working, Presentation, etc., from a drop-down list.

Of course this is not appropriate if you want your slide show view to be full-screen. But if you're toggling between slide show and working, it's likely this is something you might be doing during development of your notebook rather than during its presentation to an audience.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.