6
$\begingroup$

I use two finger movement on my trackpad for scrolling a notebook page up and down. Is it possible to make a docked cells that scrolls to the left and right using a two finger movement on the trackpad?

The reason I ask is because sometimes my notebook window is not full screen. My notebook needs to be in full screen mode to see the entire docked cell. I have lots of buttons that can't be seen if it is not. I don't want to make the buttons smaller than they already are.

It would be nice to have a way to scroll to the right and left to reach the buttons without resizing the notebook window. Is this possible?

$\endgroup$
6
  • 1
    $\begingroup$ You could wrap the content with Pane with Scrollbars and it seem it partially works, can't use the bar itself but arrows at its ends are. Maybe a grid of buttons is a solution, or do you insist on having one? $\endgroup$ Commented Nov 27, 2015 at 10:52
  • $\begingroup$ Thank you Kuba. I would like to be able to use two finger gesture instead of manually clicking the scrollbar. I would prefer if the scrollbar wasn't present at all. I could do as you suggested and create a grid instead of row, but was trying to avoid this as it would make my toolbar taller which cuts into my viewing area. $\endgroup$ Commented Nov 27, 2015 at 10:58
  • 1
    $\begingroup$ Try GestureHandler with Alignment or a ScrollPosition, can't test now, no pad around ;) $\endgroup$ Commented Nov 27, 2015 at 11:02
  • $\begingroup$ I will! Thanks again Kuba. If this works, I'll post my solution. $\endgroup$ Commented Nov 27, 2015 at 11:15
  • $\begingroup$ It looks like the gesture handler is for touch devices only. It doesn't recognize the gestures on the trackpad on my mac. $\endgroup$ Commented Nov 27, 2015 at 13:41

1 Answer 1

5
$\begingroup$

Using MMA 11.0.0 the following works to create a scrollable docked cell:

setScrollingDockedCell[expr_] := SetOptions[EvaluationNotebook[], DockedCells -> Cell[BoxData@ToBoxes@ Pane[expr, ImageSize -> Scaled[1] ] ] ]; 

Note that the ImageSize -> Scaled[1] is crucial here. Without an explicit ImageSize no scrolling occurs. Scaled[1] sticks the expression on a single line. Something ludicrous like ImageSize -> 100000000 will also work.

This works with all of the expressions I've tried:

setScrollingDockedCell@ Row@Table[ With[{i = i}, PasteButton[i] ], {i, Range[100]} ] setScrollingDockedCell@ Grid@Table[ With[{i = i}, PasteButton[Row@{i, j}, {i, j}] ], {i, Range[3]}, {j, Range[100]} ] setScrollingDockedCell@ Pane[Graphics[{ Disk[{0, 0}, 1000], {White, Disk[{0, 0}, {100, 900}]}, {Green, Disk[{0, 0}, {75, 750}]}, {Black, Disk[{0, 0}, {50, 500}]}, Disk[{2000, 0}, 1000], {White, Disk[{2000, 0}, {100, 900}]}, {Green, Disk[{2000, 0}, {75, 750}]}, {Black, Disk[{2000, 0}, {50, 500}]} }, AspectRatio -> Full, ImageSize -> 1000], {Automatic, 25}] 

All of those work

It seems to balk when there's a lot of blank space in the expression though:

setScrollingDockedCell@Range[1000] 

That only starts scrolling when you have the cursor over one of the expression elements (a number/bracket/comma I mean)

Perhaps this is new as of 11 but I don't have a copy of 10 to test. It is very useful for things like tabbed windows though.

$\endgroup$
1
  • $\begingroup$ Works in 10.3 as well. $\endgroup$ Commented Nov 25, 2016 at 2:55

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.