Home › Forums › General › Programming › User text input for uiListBox?
Tagged: AlertWindow, askForTextInputWindow, uiLabel
- This topic has 13 replies, 3 voices, and was last updated 3 years, 2 months ago by
dnaldoog.
-
AuthorPosts
-
September 24, 2020 at 5:21 am #120021
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,
September 24, 2020 at 8:26 pm #120024Hi, 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!
September 24, 2020 at 8:30 pm #120025FYI, 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)September 25, 2020 at 12:22 am #120027Thanks for the advice Dnaly, looking into it – also looking forward to seeing your reply goodweather.
Cheers
September 25, 2020 at 5:30 am #120029Dnaldoooooooooog. 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?
September 25, 2020 at 7:58 am #120031Do 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.
September 25, 2020 at 8:59 am #120032FYI, 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 3 years, 2 months ago by
dnaldoog.
September 25, 2020 at 3:54 pm #120035OK 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!
September 27, 2020 at 12:25 pm #120058※ 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 3 years, 1 month ago by
dnaldoog.
September 27, 2020 at 11:32 pm #120068Big 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.
September 28, 2020 at 10:45 am #120071Do you mean last item clicked on or last item in the uiListBox? The question is a little ambiguous.
-
This reply was modified 3 years, 2 months ago by
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.