Setting a default value for a combo and Text block in AlertWindow

Home Forums General Programming Setting a default value for a combo and Text block in AlertWindow

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #66685
    goodweather
    Participant
      • Topics: 45
      • Replies: 550
      • Total: 595
      • ★★★

      Hi,
      wanted to modify some data by using an AlerWindow containing a Text box (name), Combo box (category) and Text block (longer description).
      It is possible to set a default value for the Text box but is it for the Combo box?

      modalWindow = AlertWindow("\n\nModify patch name, category and description", " ", AlertWindow.InfoIcon)
      modalWindow:addButton("    OK    ", 1, KeyPress(KeyPress.returnKey),KeyPress())
      modalWindow:addButton("Cancel", 0, KeyPress(KeyPress.escapeKey),KeyPress())
      modalWindow:addTextEditor ("txtPatchName", "My patch", "Name", false)
      modalWindow:addComboBox ("cmbCategory", saCategories, "Category")
      modalWindow:addTextEditor ("txtPatchDescription", "This patch is fantastic...", "Description", false)
      modalWindow:addTextBlock ("Don't forget to save your changes afterwards with the Save button...")
      

      Also, is it possible to define the number of lines displayed in a Text block? I get only one line and scrollbars…
      How to retrieve the selected combo box item? Saw it was with getComboBoxComponent…
      How to retrieve the content of a Text block (or is this for display only and not for editing?)

      Looked in Juce but didn’t find.

      If all of this is not working then I’ll just use classical Ctrlr components in another tab…

      Thx in advance for the reply!

      #67282
      atom
      Keymaster
        • Topics: 159
        • Replies: 2945
        • Total: 3104
        • ★★★★★

        I’m working on that.

        Can you paste me a full example with a popup window, i’m trying to figure out a way to do this right anyway, there are many and i was wondering witch one you chose. I think i also need to fix the handling of those windows anyway.

        #67289
        goodweather
        Participant
          • Topics: 45
          • Replies: 550
          • Total: 595
          • ★★★

          Haha…Good!
          Here is the code

          --
          -- Called when a modulator value changes
          -- @modulator   http://ctrlr.org/api/class_ctrlr_modulator.html
          -- @modValue    new numeric value of the modulator
          --
          RenamePatch = function(modulator, modValue)
          
          	if isPanelReady() then
          
          		saCategories = StringArray()
          		saCategories:set(0, String("Miscellaneous"))
          		saCategories:set(1, String("Classic"))
          		saCategories:set(2, String("Duo"))
          		saCategories:set(3, String("Drone"))
          		saCategories:set(4, String("Noise"))
          		saCategories:set(5, String("Bass"))
          		saCategories:set(6, String("Lead"))
          		saCategories:set(7, String("Brass"))
          		saCategories:set(8, String("Woodwind"))
          		saCategories:set(9, String("Sound FX"))
          		saCategories:set(10, String("Keys"))
          		saCategories:set(11, String("Organs"))
          		saCategories:set(12, String("Sync"))
          		saCategories:set(13, String("Strings"))
          		saCategories:set(14, String("Pads"))
          		saCategories:set(15, String("Evolving"))
          		saCategories:set(16, String("Distorted"))
          		saCategories:set(17, String("Vox"))
          		saCategories:set(18, String("Arp"))
          		saCategories:set(19, String("Sequence"))
          		saCategories:set(20, String("Percussion"))
          		saCategories:set(21, String("User"))
          		
          		modalWindow = AlertWindow("\n\nModify patch name, category and description", " ", AlertWindow.InfoIcon)
          		modalWindow:addButton("    OK    ", 1, KeyPress(KeyPress.returnKey),KeyPress())
          		modalWindow:addButton("Cancel", 0, KeyPress(KeyPress.escapeKey),KeyPress())
          		modalWindow:addTextEditor ("txtPatchName", "My patch", "Name", false)
          		modalWindow:addComboBox ("cmbCategory", saCategories, "Category")
          		modalWindow:addTextEditor ("txtPatchDescription", "This patch is fantastic...", "Description", false)
          		modalWindow:addTextBlock ("Don't forget to save your changes afterwards with the Save button...")
          		--modalWindow:setModalHandler(windowCallback)
          
          		ret = modalWindow:runModalLoop()
          
          		-- runModalLoop() returns a number that indicates what button was pressed to dismiss the window
          		if ret == 0 then
          			--console("Cancel")
          		end
          		if ret == 1 then
          			--console("OK")
          			textEditor = modalWindow:getTextEditor("txtPatchName"):getText()
          			if textEditor ~= nil then
          				txtPresetName:getComponent():setProperty("uiLabelText", textEditor, false)
          			end
          			if textEditor == "" then
          				txtPresetName:getComponent():setProperty("uiLabelText", "Untitled Patch", false)
          			end
          		end
          		modalWindow:setVisible (false)
          	end
          
          end

          While looking for this I got something weird…
          I had my Sub37 panel opened (it contains the code above) then I opened my test panel (the one I attached in the CC/NRPN feedback topic) and suddenly the Rename modal window opened by itself… Should definitively not happen as this is in another panel.
          If needed I can post you the Sub37 panel. As Moog announced their editor, I will know simply try to finalize with what I discovered but I’m still lacking all NRPNs for the sequencer, I don’t know how to calculate the checksum so I cannot save files and I don’t know how to request a patch. At least it is doing what I wanted: load a patch and display all buttons positions and parameters.
          Btw, I also adapted dasfaker’s enveloppe graph by making it fully flexible in terms of XY size. So, I could post it in a separate simple panel with some explanations.

          I’ll work on a panel for my new DSI Pro2. Will use your bit packing stuff for sure…And at least for that one, everything is documented. So no more hours reverse engineering analysis of sysex as Moog don’t provide any Sub37 documentation.

          #67361
          atom
          Keymaster
            • Topics: 159
            • Replies: 2945
            • Total: 3104
            • ★★★★★

            try this


            saCategories = StringArray()
            saCategories:set(0, String("Miscellaneous"))
            saCategories:set(1, String("Classic"))
            saCategories:set(2, String("Duo"))
            saCategories:set(3, String("Drone"))
            saCategories:set(4, String("Noise"))
            saCategories:set(5, String("Bass"))
            saCategories:set(6, String("Lead"))
            saCategories:set(7, String("Brass"))
            saCategories:set(8, String("Woodwind"))
            saCategories:set(9, String("Sound FX"))
            saCategories:set(10, String("Keys"))
            saCategories:set(11, String("Organs"))
            saCategories:set(12, String("Sync"))
            saCategories:set(13, String("Strings"))
            saCategories:set(14, String("Pads"))
            saCategories:set(15, String("Evolving"))
            saCategories:set(16, String("Distorted"))
            saCategories:set(17, String("Vox"))
            saCategories:set(18, String("Arp"))
            saCategories:set(19, String("Sequence"))
            saCategories:set(20, String("Percussion"))
            saCategories:set(21, String("User"))

            modalWindow = AlertWindow("\n\nModify patch name, category and description", " ", AlertWindow.InfoIcon)
            modalWindow:addButton(" OK ", 1, KeyPress(KeyPress.returnKey),KeyPress())
            modalWindow:addButton("Cancel", 0, KeyPress(KeyPress.escapeKey),KeyPress())
            modalWindow:addTextEditor ("txtPatchName", "My patch", "Name", false)
            modalWindow:addComboBox ("cmbCategory", saCategories, "Category")
            modalWindow:addTextEditor ("txtPatchDescription", "This patch is fantastic...", "Description", false)
            modalWindow:addTextBlock ("Don't forget to save your changes afterwards with the Save button...")
            --modalWindow:setModalHandler(windowCallback)

            ret = modalWindow:runModalLoop()

            -- runModalLoop() returns a number that indicates what button was pressed to dismiss the window
            if ret == 1 then
            patchName = modalWindow:getTextEditorContents("txtPatchName")
            patchDesc = modalWindow:getTextEditorContents("txtPatchDescription")
            patchCat = modalWindow:getComboBoxComponent("cmbCategory"):getText()

            console ("name: " .. patchName .. " desc: " .. patchDesc .. " cat: " .. patchCat)
            end
            modalWindow:setVisible (false)

            • This reply was modified 8 years, 4 months ago by atom.
          Viewing 4 posts - 1 through 4 (of 4 total)
          • The forum ‘Programming’ is closed to new topics and replies.
          There is currently 0 users and 168 guests online
          No users are currently active
          Forum Statistics
          Threads: 2,495, Posts: 17,374, Members: 77,605
          Most users ever online was 12 on January 22, 2019 3:47 pm
          Ctrlr