User text input for uiListBox?

Home Forums General Programming User text input for uiListBox?

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #120021
    Jsh
    Participant
    • Topics: 6
    • Replies: 12
    • Total: 18

    Hey guys,

    I’ve been working on a program/patch library for my panel, and at the moment I’m using uiListBox saving program data and names to a table and using “utils.askForTextInputWindow(etc)” to bring up a window to name the program on save and this text is used to set the name of the current patch in the table which the stores all of the names in order in a string with newline \n to be used to set the table contents with “setPropertyString(“uiListBoxContent”, patchList)” which works fine…But ideally if possible I would like the user to be able to rename a program without using a separate dialogue window, (ie. ask for text window) but instead just enter the text in place of the current program name / table row name.

    Any ideas as to how to approach this or if this is do-able?

    Cheers,

    #120024
    goodweather
    Participant
    • Topics: 45
    • Replies: 546
    • Total: 591
    • ★★★

    Hi, not sure if I fully understand what you want to achieve…
    So, I’m assuming you have a listbox containing all your patches and you want to save the one which is selected.

    I’m doing the following in my librarian (as in my Pro 2 or Prologue panel):
    – I have a separate uiLabel that gets populated when the user clicks on one line in the listbox
    – I have a “program action” pulldown and Proceed button that allows performing many different operations. One of them is Save to single file. Here is the code as example (txtSource is the uiLabel that contains the selected patch, mbSynth1 is a memory block containing all programs listed in the listbox)

    	-- Save program to disk ((single program .syx file - always a 392 single program buffer dump to be bank and program independent)
    	elseif iAction==6 then
    
    		if txtSource:getComponent():getProperty("uiLabelText")=="" then
    			utils.warnWindow("Save program to disk", "Error: you must have a source program to perform a Save.\nLoad banks, select a source program (left-click) then retry the Save action.")
    			return
    		end
    
    		-- No usage of bConfirm here as you have the occasion to Cancel in the Save File dialog box
    
    		-- Prepare program data memoryblock
    		iSourceProgram = tonumber(string.sub(txtSource:getComponent():getProperty("uiLabelText"), 5, 7))-1
    		mbTemp = MemoryBlock ({0xF0, 0x42, 0x30, 0x00, 0x01, 0x4B, 0X40})
    		mbTemp:append (mbSynth1:getRange(9+iSourceProgram*394, 385))
    		
    		f = utils.saveFileWindow ("Save Prologue single program dump sysex file", File(""), "*.syx", true)
    		if f:isValid() then
    			if f:existsAsFile()==false then
    				f:create()
    			end
    			f:replaceWithData(mbTemp)
    			utils.infoWindow("Save program to disk", "Program '"..txtSource:getComponent():getProperty("uiLabelText").."' saved in \n"..f:getFullPathName())
    		end
    

    Good luck!

    #120025
    goodweather
    Participant
    • Topics: 45
    • Replies: 546
    • Total: 591
    • ★★★

    FYI, I made a long reply but don’t see my text after an edit…
    Will wait till tomorrow to see if it gets published. If not, I’ll redo it (I did a copy /paste of the text)

    #120027
    Jsh
    Participant
    • Topics: 6
    • Replies: 12
    • Total: 18

    Thanks for the advice Dnaly, looking into it – also looking forward to seeing your reply goodweather.

    Cheers

    #120029
    Jsh
    Participant
    • Topics: 6
    • Replies: 12
    • Total: 18

    Dnaldoooooooooog. Thanks for the advice, this works quite nicely for me. Quick related question, does anyone know how I can keep the last item in the uiListBox highlighted when I click somewhere else in my panel/unfocus the modulator?

    #120031
    dnaldoog
    Participant
    • Topics: 4
    • Replies: 470
    • Total: 474
    • ★★

    Do you mean last item clicked on or last item in the uiListBox? It seems to me if you click on an item it stays highlighted when unfocused.

    #120032
    dnaldoog
    Participant
    • Topics: 4
    • Replies: 470
    • Total: 474
    • ★★

    FYI, I made a long reply but don’t see my text after an edit…
    Will wait till tomorrow to see if it gets published. If not, I’ll redo it (I did a copy /paste of the text)

    Hi Goodweather,

    When that happens, it probably means it’s gone forever (did you edit and save a third time?) – so you would have to now paste/re-submit that saved message.

    Regards,

    John

    • This reply was modified 1 month ago by dnaldoog.
    #120035
    goodweather
    Participant
    • Topics: 45
    • Replies: 546
    • Total: 591
    • ★★★

    OK guys, I see it is indeed gone.. So here it is again (yesterday I couldn’t post it twice…).

    Hi, not sure if I fully understand what you want to achieve…
    So, I’m assuming you have a listbox containing all your patches and you want to save the one which is selected.

    I’m doing the following in my librarian (as in my Pro 2 or Prologue panel):
    – I have a separate uiLabel that gets populated when the user clicks on one line in the listbox
    – I have a “program action” pulldown and Proceed button that allows performing many different operations. One of them is Save to single file. Here is the code as example (txtSource is the uiLabel that contains the selected patch, mbSynth1 is a memory block containing all programs listed in the listbox)

    	-- Save program to disk ((single program .syx file - always a 392 single program buffer dump to be bank and program independent)
    	elseif iAction==6 then
    
    		if txtSource:getComponent():getProperty("uiLabelText")=="" then
    			utils.warnWindow("Save program to disk", "Error: you must have a source program to perform a Save.\nLoad banks, select a source program (left-click) then retry the Save action.")
    			return
    		end
    
    		-- No usage of bConfirm here as you have the occasion to Cancel in the Save File dialog box
    
    		-- Prepare program data memoryblock
    		iSourceProgram = tonumber(string.sub(txtSource:getComponent():getProperty("uiLabelText"), 5, 7))-1
    		mbTemp = MemoryBlock ({0xF0, 0x42, 0x30, 0x00, 0x01, 0x4B, 0X40})
    		mbTemp:append (mbSynth1:getRange(9+iSourceProgram*394, 385))
    		
    		f = utils.saveFileWindow ("Save Prologue single program dump sysex file", File(""), "*.syx", true)
    		if f:isValid() then
    			if f:existsAsFile()==false then
    				f:create()
    			end
    			f:replaceWithData(mbTemp)
    			utils.infoWindow("Save program to disk", "Program '"..txtSource:getComponent():getProperty("uiLabelText").."' saved in \n"..f:getFullPathName())
    		end
    

    Good luck!

    #120058
    dnaldoog
    Participant
    • Topics: 4
    • Replies: 470
    • Total: 474
    • ★★

    ※ I tried re-editing the post, but it got nuked, so I am reposting it here!


    Hi Jsh,

    You can create a callback function for a uiLabel using:

    Called When the Label Content changes

    and you can mask user input using the field Allowed characters the user can input

    That should work!


    note:

    With askForTextInputWindow() it seems you can’t tell whether Okay/Cancel was clicked, so AlertWindow() is probably more useful

    https://ctrlr.org/forums/topic/ctrlrluautils/#post-6489

    For an example of how to use AlertWindow() see:

    https://ctrlr.org/generic-sysex-dump-editor/

    Regards.

    • This reply was modified 2 weeks, 5 days ago by dnaldoog.
    #120068
    Jsh
    Participant
    • Topics: 6
    • Replies: 12
    • Total: 18

    Big thanks to both of you guys, very helpful. As for the other issue:

    Dnaldoooooooooog. Thanks for the advice, this works quite nicely for me. Quick related question, does anyone know how I can keep the last item in the uiListBox highlighted when I click somewhere else in my panel/unfocus the modulator?

    this is just happening when I enter the new patch name into the label and press enter, so I’m guessing when I do this I could also just do a set modulator value again on the list box (from the uiLabel on pressed enter) and it should re-highlight the selected row. Haven’t tried this yet though.

    #120071
    dnaldoog
    Participant
    • Topics: 4
    • Replies: 470
    • Total: 474
    • ★★

    Do you mean last item clicked on or last item in the uiListBox? The question is a little ambiguous.

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.
There is currently 0 users and 35 guests online
No users are currently active
Forum Statistics
Threads: 2,442, Posts: 17,213, Members: 52,905
Most users ever online was 12 on January 22, 2019 3:47 pm
Do NOT follow this link or you will be banned from the site!