Jump to content


Photo

Reopening a vb-view, how to do? + other


  • Please log in to reply
2 replies to this topic

#1 ffx

ffx

    Composes without Wires burns Directly from Brain to DVD that is already in Store Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3482 posts
  • Gender:Not Telling

Posted 01 February 2018 - 15:12

Hi,

 

I setup a vbview and now would like to close it and the re-open it. I stumbled here over 2 problems:

 

- dialogPtr:close() and then dialogPtr:show() does not work. Shouldn't it at least reopen the thing? Is there a method for "regenerate" or similar?

 

- If I want to rebuild it, it throws an error "'custom_dialog: content view was already added to some other view or dialog.'"

 

Obviously I did not yet fully understand the logic behind this.

 

What I want is to regenerate / rebind the dialogue and then reopen it. I already tried to wrap it into a function and calling it recursively, but wasn't successful.

 

 

The third question is, how to target a control itself within the notifier-function? Let say this code:

                vb:textfield {
                    value = tostring(data[index]), 
                    width = 80, 
                    tooltip = val.txt, 
                    notifier = function(newValue)
                        if (tonumber(newValue) == nil) then
                            renoise.app():show_error("Only use numeric values in the field "..index.."!")
                        else
                            data[index] = tonumber(newValue)
                            if (callbackRefresh ~= nil) then
                                callbackRefresh(data)
                            end
                        end
                    end, 

On error, I also want to reset the value of that textfield. How can I address it in the most easy way? Am I forced to use an id then?

 

In Javascript afaik "this" always targets the most inner scope, so here this would be super easy (I even can do this.parent etc). In lua it seems that "self" only is available for classes / outer objects?


Edited by ffx, 01 February 2018 - 15:16.

Test system: macOS 10.13.4, HFS+. Firewire Audio, i7 4770, 8GB Ram, GTX1050 2GB, 48kHz
GUI Automation RecorderNative DSP Context MenuTuned ShortcutsUnified Value Shift And Transpose | Jump To From Send Modified (Docs) | Quick Template | Nisanmol's Groove Tool FixedThemes


#2 danoise

danoise

    Probably More God or Borg Than Human Member

  • Renoise Team
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 6966 posts
  • Gender:Male
  • Location:Berlin
  • Interests:wildlife + urban trekking

Posted 01 February 2018 - 15:24

Yeah, the logic for opening/rebuilding dialogs can be a bit complex.
I've had good experiences with the approach used in vLib:
https://github.com/r...vDialog.lua#L74

As for how to target a control itself, you just add an 'id' property to your element.
Then you can access it from anywhere in that viewbuilder instance, using this syntax:
 

vb:button{
 id = "my_button",
 notifier = function()
  local the_button = vb.views["my_button"]
  the_button.active = false
 end 
}

But, be aware that once you absolutely need to destroy views with ids if you plan on (re-)building them - an id can be defined only once (it's unique).

Sometimes, it's preferable to just make a reference to your vb element, like this: 

local my_button = nil

local my_button_handler = function()
  my_button.active = false
end

my_button = vb:button{
 notifier = function()
  my_button_handler()
 end 
}

Both are valid approaches, sometimes one fits better than the other.


  • ffx and Raul (ulneiz) like this

Tracking with Stuff. API wishlist | Soundcloud


#3 ffx

ffx

    Composes without Wires burns Directly from Brain to DVD that is already in Store Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3482 posts
  • Gender:Not Telling

Posted 01 February 2018 - 15:27

Very helpful, thanks!


Test system: macOS 10.13.4, HFS+. Firewire Audio, i7 4770, 8GB Ram, GTX1050 2GB, 48kHz
GUI Automation RecorderNative DSP Context MenuTuned ShortcutsUnified Value Shift And Transpose | Jump To From Send Modified (Docs) | Quick Template | Nisanmol's Groove Tool FixedThemes