HISE Logo Forum
    • Categories
    • Register
    • Login

    min max value next prev btn

    Scheduled Pinned Locked Moved General Questions
    6 Posts 2 Posters 287 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Y
      yall
      last edited by

      inline function onnextControl(component, value)
      {
      	viewport.setValue((viewport.getValue() + 1));
      	viewport.changed();
      	
      };
      
      Content.getComponent("next").setControlCallback(onnextControl);
      

      hello, I am trying to make a next/prev button from my preset list in a viewport. it works but if I press prev once the first preset in my list is selected my viewport continues to scroll in vain. as if there was no min and max value. I don't know if you understand. To put it simply, I would simply like to navigate from the first to the last preset without it going over. if I have 10 presets I want to be able to navigate between my 10 presets and not -1 preset -2 preset 11, 12 13 preset. :) what is missing from my line? I tried getmaxValue but to no avail

      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @yall
        last edited by

        @yall

        You need to check if the new value will exceed the min/max before you apply it.

        inline function onnextControl(component, value)
        {
            if (viewport.getValue() + 1 > viewport.get("max"))
              return;
        
            viewport.setValue((viewport.getValue() + 1));
            viewport.changed();
        };
        

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        1 Reply Last reply Reply Quote 0
        • d.healeyD
          d.healey
          last edited by

          Actually I just realised the viewport doesn't have a max property so you'll need to decide what you max is some other way. But apart from that the principle is the same.

          Libre Wave - Freedom respecting instruments and effects
          My Patreon - HISE tutorials
          YouTube Channel - Public HISE tutorials

          Y 1 Reply Last reply Reply Quote 0
          • Y
            yall @d.healey
            last edited by

            @d-healey and yes that is the problem. so I should probably know how many presets I have. imagine 150 I must put max=150?

            d.healeyD 1 Reply Last reply Reply Quote 0
            • d.healeyD
              d.healey @yall
              last edited by

              @yall Or you could use Engine.getUserPresetList().length to find out the actual number.

              Libre Wave - Freedom respecting instruments and effects
              My Patreon - HISE tutorials
              YouTube Channel - Public HISE tutorials

              Y 1 Reply Last reply Reply Quote 0
              • Y
                yall @d.healey
                last edited by

                @d-healey

                if (value)
                {
                    viewport.setValue( viewport.getValue() == 0 ? list.length-1 :  viewport.getValue() - 1);
                     viewport.changed();
                }
                

                it's ok ;) thank u

                1 Reply Last reply Reply Quote 1
                • First post
                  Last post

                44

                Online

                1.7k

                Users

                11.7k

                Topics

                101.8k

                Posts