Skip navigation

Scroll in the sheet pane with the keyboard, possible?

947 Views 29 Replies Latest reply: Feb 15, 2013 1:52 AM by fred6633 RSS
1 2 Previous Next
fred6633 Calculating status...
Currently Being Moderated
Feb 12, 2013 8:26 AM

I have document that contains about 40 sheet. Therefore I would like to be able to scroll in the sheet pane with the keyboard. However, I haven't found a way. Command - Page up and Command - Page down select previous and next sheet. Command - home and Command - end select first and last sheet. But the scrollbar remains in its position.

 

If someone could give me an applescript that took the scrollbar in the sheet pane to home and end, would that be apprecited.

 

Fred

iMac, Mac OS X (10.6.8)
  • Hiroto Level 5 Level 5 (4,810 points)

    Hello

     

    Try something like this.

     

    (*
        set scroll bar position of sheets area of Numbers 09
            0.0 = top
            1.0 = bottom
    *)
    tell application "System Events"
        tell process "Numbers"
            --set frontmost to true
            tell window 1
                tell splitter group 1 -- document pane
                    tell splitter group 1 -- side pane
                        tell scroll area 1 -- sheets area
                            tell scroll bar 1
                                if exists then
                                    set value to 1.0 -- [0.0, 1.0]
                                end if
                            end tell
                        end tell
                    end tell
                end tell
            end tell
        end tell
    end tell
    

     

    Scroll bar's value is in [0.0, 1.0].

    0.0 is the top, 1.0 is the bottom, 0.5 is middle, etc.

     

    Regards,

    H

  • Badunit Level 6 Level 6 (10,760 points)
    Currently Being Moderated
    Feb 12, 2013 11:57 AM (in response to Hiroto)

    I have this little snippet of script that might be the basis for scrolling through the sheet pane. It does not require there to be a scroll bar present. As written it will go to the second sheet and give that sheet focus. In the line "set targetSheetRow to second row...", if you change "second" to "first" or "third" (etc.) or "last" it will go to the that sheet instead. I'm not sure how to take this any further and turn it into a scroll script, though.

     

     

     

    tell application "System Events" to tell application process "Numbers"

              tell outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of front window

                        set targetSheetRow to second row where ((value of attribute "AXDisclosureLevel" is 0))

     

                        tell targetSheetRow to set {value of attribute "AXSelected", value of attribute "AXDisclosing"} to {true, true}

      -- Focus the "Sheets" column ('outline 1 …') AFTER the target row is selected.

                        set value of attribute "AXFocused" to true

                        delay 0.1

              end tell

    end tell


  • Badunit Level 6 Level 6 (10,760 points)

    A slight mod to Hiroto's script will let you bounce back and forth from top to bottom

     

    tell application "System Events"

              tell process "Numbers"

      --set frontmost to true

                        tell window 1

                                  tell splitter group 1 -- document pane

                                            tell splitter group 1 -- side pane

                                                      tell scroll area 1 -- sheets area

                                                                tell scroll bar 1

                                                                          if exists then

                                                                                    if value is 0.0 then

                                                                                              set value to 1.0 -- [0.0, 1.0]

                                                                                    else

                                                                                              set value to 0.0

                                                                                    end if

                                                                          end if

                                                                end tell

                                                      end tell

                                            end tell

                                  end tell

                        end tell

              end tell

    end tell

  • Badunit Level 6 Level 6 (10,760 points)

    Good idea to have multiple steps. However, it only scrolls downward then gets stuck at the bottom. Another IF would fix that.

     

    Here is a script that will scroll down the sheets one by one, moving the focus to the sheet. When at the last sheet, it will take you to the top sheet. Sorry about the poor formatting.

     

    tell application "System Events" to tell application process "Numbers"

              tell outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of front window

      -- Find the sheet that is currently being displayed

                        set currentSheetRow to first row where ((value of attribute "AXDisclosureLevel" is 0) and (value of attribute "AXSelected" is 1))

     

      -- Try to move to the next sheet. If at thebottom, go to the first sheet

                        try

                                  set targetSheetRow to first row where ((value of attribute "AXDisclosureLevel" is 0) and (value of attribute "AXSelected" is 0) and (value of attribute "AXIndex" is greater than (value of attribute "AXIndex" of currentSheetRow)))

                        on error

                                  set targetSheetRow to first row where (value of attribute "AXDisclosureLevel" is 0)

                        end try

     

                        tell targetSheetRow to set {value of attribute "AXSelected", value of attribute "AXDisclosing"} to {true, true}

     

      -- Focus the sheet after the target row is selected.

                        set value of attribute "AXFocused" to true

              end tell

    end tell

  • Badunit Level 6 Level 6 (10,760 points)

    fred6633 wrote:

     

    Thanks,

     

    My idea was to have one for downwards and one for upwards.

     

    There is already a key that goes down up one leverl, Cmd end and Cmd home.

     

    Given the subject of this thread, I had assumed there was no way to scroll through the Sheets pane with the keyboard. It is not something I ever needed to do. But it turns out you are correct. There are built-in shortcuts for scrolling sheet by sheet (as I was trying to do) and for going to the top and bottom of the list of sheets (as Hiroto did). Cmd Page Up and Cmd Page Down are the two shortcuts for going up/down one sheet. Cmd Home and Cmd End go to the top and bottom.

  • Jeff Shenk Level 4 Level 4 (2,000 points)

    Badunit,

     

    I think the problem is that while the existing shortcuts move the focus up and down, the view doesn't scroll with the focus, so you can't see where you are if you have more sheets than fit in the window.

  • Badunit Level 6 Level 6 (10,760 points)

    Jeff Shenk wrote:

     

    Badunit,

     

    I think the problem is that while the existing shortcuts move the focus up and down, the view doesn't scroll with the focus, so you can't see where you are if you have more sheets than fit in the window.

     

    I think I need to brush up on my reading comprehension skills. I went off to solve a problem that wasn't the problem (and wasn't a problem at all for that matter).

1 2 Previous Next

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.