No internet connection
  1. Home
  2. How to
  3. Pro Tools

Issue with selecting track size popup menu

By Mitch Willard @Mitch_Willard
    2024-03-17 01:08:44.577Z

    Hi @chrscheuer & @Kitch

    There seems to be an issue in selecting the popup menu for track size in the latest version 5.7.1, which was a similar issue that happen in 5.7.0 when selecting a tracks titleButton popup menu (seems fixed in 5.7.1) where it deselects the selected track which then results in it failing to open up the popup menu to select the track size.

    cheers

    Mitch

    function trackSize({ sizeOfTracks }) {
    
    
        var selectedTrack = sf.ui.proTools.selectedTrack
        var f = selectedTrack.frame;
    
        selectedTrack.trackScrollToView();
    
        var popupMenu = selectedTrack.popupMenuOpenFromElement({
            relativePosition: { x: f.w - 10, y: 5 },
            isOption: true,
        }).popupMenu;
    
    
        popupMenu.menuClickPopupMenu({
            menuPath: [sizeOfTracks]
        });
    
    
    };
    
    trackSize({ sizeOfTracks: 'small' });
    
    
    Solved in post #4, click to view
    • 10 replies
    1. Hi Mitch,

      You will need to specify the anchor property and set it to 'TopLeft', as such:

      var popupMenu = selectedTrack.popupMenuOpenFromElement({
              relativePosition: { x: f.w - 10, y: 5 },
              anchor: 'TopLeft',
              isOption: true,
          }).popupMenu;
      
      1. The longer reply: We changed popupMenuOpenFromElement to by default click on the center of the element. By specifying the anchor property, you're overriding that behavior to go back to what it used to be (top left corner, which your relative position calculation here depends on)

        1. Note, this also means you can now write the entire script more simply like this:

          var selectedTrack = sf.ui.proTools.selectedTrack;
          
          selectedTrack.trackScrollToView();
          
          selectedTrack.popupMenuSelect({
              relativePosition: { x: -10, y: 0 },
              anchor: 'MidRight',
              isOption: true,
              menuPath: ['small'],
          });
          
          Reply1 LikeSolution
          1. Mitch Willard @Mitch_Willard
              2024-03-17 02:36:02.755Z

              Cheers for that @chrscheuer, too easy! Super simple fix.

              1. In reply tochrscheuer:
                Mitch Willard @Mitch_Willard
                  2024-03-18 01:01:49.465Z

                  Hey @chrscheuer,

                  This is working perfect. Thanks for this.

                  Though now, we have a few scripts that will fetch the current size of the track using .popupMenuFetchAllItems() to return it to that size after a script which doesn't have the option to anchor the mouse click to open up the track size. Will this be getting added?

                  I tried using the tracks frame but to no luck, even though it places the mouse in the correct position.

                  var selectedTrack = sf.ui.proTools.selectedTrack
                  
                  var currentTrackSize = selectedTrack.popupMenuFetchAllItems({
                      relativePosition: { x: selectedTrack.frame.w, y: selectedTrack.frame.y + 5 },
                  }).menuItems.filter(mi => mi.element.isMenuChecked)[0].names[0];
                  
                  log(currentTrackSize)   
                  
                  1. Thanks! I'll add anchor to popupMenuFetchAllItems in SF 5.7.5 :)

                    1. Mitch Willard @Mitch_Willard
                        2024-03-18 01:50:17.626Z

                        awesome @chrscheuer ! you're the best!

              2. D
                In reply toMitch_Willard:
                Dean Landon @Dean
                  2024-03-18 05:07:06.274Z

                  Hi Christian,

                  I tried this script:

                  var selectedTrack = sf.ui.proTools.selectedTrack;

                  selectedTrack.trackScrollToView();

                  selectedTrack.popupMenuSelect({
                  relativePosition: { x: -10, y: 0 },
                  anchor: 'MidRight',
                  isOption: true,
                  menuPath: ['small'],
                  });

                  ...but after running it, all my tracks are small. Any way of selecting certain tracks so that only the ones high-lighted are small?

                  Thanks!

                  1. Mitch Willard @Mitch_Willard
                      2024-03-18 05:11:38.223Z

                      Here you go @Dean

                      
                      function trackSizeSelectedTracks({ sizeOfTracks }) {
                      
                          var selectedTrack = sf.ui.proTools.selectedTrack
                      
                          selectedTrack.trackScrollToView();
                      
                          selectedTrack.popupMenuSelect({
                              relativePosition: { x: -10, y: 0 },
                              anchor: 'MidRight',
                              isOption: true,
                              isShift: true,
                              menuPath: [sizeOfTracks],
                          });
                      
                      };
                      
                      trackSizeSelectedTracks({ sizeOfTracks: 'small' });
                      
                      
                    • D
                      In reply toMitch_Willard:
                      Dean Landon @Dean
                        2024-03-18 05:15:09.311Z

                        Thank you Mitch. Works like a charm.