HISE Logo Forum
    • Categories
    • Register
    • Login

    VIEWPORT || How can I .getItemText() or something similar??

    Scheduled Pinned Locked Moved Solved Scripting
    3 Posts 2 Posters 18 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.
    • ChazroxC
      Chazrox
      last edited by Chazrox

      Im trying to script a "delete" preset button but I need to get the item name of the selected index of my viewPort panel. Does anybody know how?

      Here's my delete script that doesnt get passed getting the name. This same script works for combobox but I switched it to a viewport panel and I cant get it to work without getting the name.

      please help 🙏
      Thanks!

      inline function onbtnSynthDeletePresetControl(component, value)
      {
          if (!value)
              return;
      	//-------------------------------------------------------------------
          local selectedIndex = vpSynthPresets.getValue();
          
          Console.print(selectedIndex);
          
          if (selectedIndex <= 0)
              return;
      	//-------------------------------------------------------------------
          // Get preset name
             
                    //-----------------THIS HERE NOT WORKING----------------------//
                  reg presetNameToDelete = vpSynthPresets.getItemText(); // THIS NOT WORKING HERE
      	Console.print(presetNameToDelete);
      	
      	if (!isDefined(SynthAndFXPresetsFile[presetNameToDelete]))
          return;
      
      
      	//-------------------------------------------------------------------			
          Engine.showYesNoWindow("Delete Preset",
              "Are you sure you want to delete \"" + presetNameToDelete + "\"?",
              function(result) // nested callback
              {	
              	var thisValueNOW = vpSynthPresets.getValue();
                  if (result)  // IF 'YES' 
                  {
                      var newPresets = {};
                      
                      for (k in SynthAndFXPresets)
                      {
                          if (k != presetNameToDelete) 
                              newPresets[k] = SynthAndFXPresets[k];
                      }
      				//-------------------------------------------------------------------					
                      SynthAndFXPresets = newPresets;
      				//-------------------------------------------------------------------					
                      SynthAndFXPresetsFile.writeObject(SynthAndFXPresets);
      				//-------------------------------------------------------------------					
                      var keyListSynth = []; // Create array for key names
                      for (k in SynthAndFXPresets) // Get key names from .json object
                          keyListSynth.push(k); // Push names to array
      				//-------------------------------------------------------------------					
                      vpSynthPresets.set("items", keyListSynth.join("\n")); // Populate Combobox
                      //-------------------------------------------------------------------	                
                      vpSynthPresets.setValue(thisValueNOW + 1); // Set to preset previous 
                      //-------------------------------------------------------------------	                
                      
                      lblSynthNameToSave.set("text", ""); // Clear text
                  }
              });
      };	
      
      Content.getComponent("btnSynthDeletePreset").setControlCallback(onbtnSynthDeletePresetControl);
      
      
      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @Chazrox
        last edited by

        @Chazrox I assume the viewport is populated from an array? If so, you can use the item index to get the value from the array.

        Use local inside inline functions rather than reg.

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

        ChazroxC 1 Reply Last reply Reply Quote 1
        • ChazroxC
          Chazrox @d.healey
          last edited by

          @d-healey this also worked! 🙏

          1 Reply Last reply Reply Quote 0
          • ChazroxC Chazrox has marked this topic as solved
          • First post
            Last post

          25

          Online

          1.9k

          Users

          12.4k

          Topics

          108.1k

          Posts