Jump to content


Photo

Bug with updating popup items?


  • Please log in to reply
4 replies to this topic

#1 Ledger

Ledger

    Guruh Motha Fakka Knows More About Renoise Than Taktik

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3645 posts
  • Gender:Male

Posted 10 September 2018 - 22:51

Not sure if this is a bug, but thought I`d mention it here.
 
If you change the .items for a popup to a table of fewer total values AND the popup is selecting a value greater than the number of new items. The popup .value remains at a now non existant value and the popup shows the default "None" entry until changed manually.

 

You might expect the value would default to 1 or 0 or nil?
 

DEMO CODE, works in testpad

--here we reduce the number of popup items from 3 to 2 while 3 is selected.  3 remains as selection value even though it doesn`t exist.

--global variables for gui
local my_dialog = nil 
local vb = nil
--assign global vb to viewbuilder
vb = renoise.ViewBuilder()

local items = {"1","2","3"}

local main_column =
   vb:column{
    vb:popup{
      id = "popup",
      items = items,
      value = 3,
    }
   }
   
  
local dialog_content = main_column
   
--Show Script dialog
my_dialog = renoise.app():show_custom_dialog("Test Popup", dialog_content)

--Now make a new table with one less item     
local less_items = {"1","2"}

--update popup to have one less item
vb.views["popup"].items = less_items

--print the popup value
print(vb.views["popup"].value) 

--this prints that the popup is still at its original value of 3. 
--Also  the popup shows the default entry "None"  until it is changed by the user or script.

Edited by Ledger, 10 September 2018 - 22:54.

--> Lua for newbies <--

My Scripts On Forum

Top Tip!

 

cpu : Xeon 1231 v3, os : Win 7 64bit, audio: Audient iD4
posts as 4tune @ KvR and some other music related sites


#2 Ledger

Ledger

    Guruh Motha Fakka Knows More About Renoise Than Taktik

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3645 posts
  • Gender:Male

Posted 10 September 2018 - 23:29

Just did a quick test and it looks like if you set value to nil, then it goes to value = 1,

 

So maybe in the above example it should default to nil.


Edited by Ledger, 10 September 2018 - 23:29.

--> Lua for newbies <--

My Scripts On Forum

Top Tip!

 

cpu : Xeon 1231 v3, os : Win 7 64bit, audio: Audient iD4
posts as 4tune @ KvR and some other music related sites


#3 Raul (ulneiz)

Raul (ulneiz)

    Guruh Motha Fakka is Levitating and Knows Everything About Renoise Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 1544 posts
  • Gender:Male
  • Location:Spain

Posted 11 September 2018 - 02:18

I do not think it's an error. Maybe you need to set the "value" of the popup for your new table "less_items" <= to the number of items:

--now make a new table with one less item
local less_items = {"1","2"}
--update popup to have one less item
local vws = vb.views
vws.popup.items = less_items
vws.popup.value = 2 --or 1 (<= #less_items)

The previous table continues to exist, it is a "local". Therefore, item 3 of the previous table is still there: items[3] = 3

 

If you change the number of items in a popup, make sure that the selection value of the popup ("value") belongs to an item in the table. In this case, the "value" index can not be greater than 2.

 

On the other hand, most objects of the API that need a range of values or items have a minimum and maximum values. For example, in a slider, I think it's from 0 to 1. You must set the values to change the ones that are by default. In the case of the popup, if the table of items is empty, "None" appears in the drop-down list. In theory, if the popup accesses to less_items[3], "None" should appear.

 

I'm just deducting things. I have not tried any of this, but if you add the last line of the code (vws.popup.value = 2), it should work correctly...

 

Edit: so as not to complicate things, if you use popups with varying tables, set from the start vws.popup.value = 1:

local main_column = vb:column {
  vb:popup {
    id = "popup",
    items = items,
    value = 1, -- <----here!
  }
}

Edited by Raul (ulneiz), 11 September 2018 - 02:28.

:excl: Development of my tools: KangarooX120SamRenderPhraseTouch  |  GT16-Colors (old)

 

:excl: My API wishlist R3.1 (updated 24 July 2017):

Spoiler

 

:excl: My Renoise 3.1 wishlist (updated 26 September 2017):

Spoiler

#4 Raul (ulneiz)

Raul (ulneiz)

    Guruh Motha Fakka is Levitating and Knows Everything About Renoise Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 1544 posts
  • Gender:Male
  • Location:Spain

Posted 11 September 2018 - 02:36

You can also add or remove items from the same table. The API has several ways to proceed to modify tables. Once the original table "items" has been modified, it would be possible to set value = #items. Thus, the code makes sure of always select the last item of the table.


:excl: Development of my tools: KangarooX120SamRenderPhraseTouch  |  GT16-Colors (old)

 

:excl: My API wishlist R3.1 (updated 24 July 2017):

Spoiler

 

:excl: My Renoise 3.1 wishlist (updated 26 September 2017):

Spoiler

#5 Ledger

Ledger

    Guruh Motha Fakka Knows More About Renoise Than Taktik

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3645 posts
  • Gender:Male

Posted 11 September 2018 - 10:06

Yes, you can of course change the value after changing the items table, and it turns out to be necessary.  However the point is that if you print vb.views["popup"].value you have no idea that what you have is an invalid index unless doing checking against .items  manually.

 

You have what looks like a valid index "hanging around" that you can `get` but would not be allowed to `set`.

 

This results in the popup showing the defult entry of "None", which you can`t cause from scripting unless you set .items = 0

 

 

Its more like the `error` is shown in the popup gui rather than in a print/script error. 


--> Lua for newbies <--

My Scripts On Forum

Top Tip!

 

cpu : Xeon 1231 v3, os : Win 7 64bit, audio: Audient iD4
posts as 4tune @ KvR and some other music related sites