Simple input dialog box?

Searching for a simple sample code for a dialog with an inputbox, ok and abort button.

I could not find any dedicated function, but this tool has something similar that you can possibly modify to your needs:
de.fladd.ChopSample.xrnx

Here is a very simple example without complicating things too much. It uses textfield, but you can change it to some other control type.

PS. I’m using show_custom_dialog instead of show_custom_prompt, since the latter steals all focus. The code would be a bit different and more simple for the prompt type.

function main()
  local vb = renoise.ViewBuilder()
  local dialog
  local textfield = vb:textfield { }

  local main_view = vb:column { margin = 4, spacing = 4,
    vb:row { margin = 4, spacing = 4, style = "group",
      vb:text {
        text = "Value"
      },
      textfield
    },
    vb:horizontal_aligner { mode = "center",
      vb:row {
        vb:button { 
          text = "Ok",
          notifier = function()
            -- do whatever with the value after hitting OK
            print(textfield.value)
            dialog:close()
          end
        },
        vb:button {
          text = "Abort",
          notifier = function() dialog:close() end
        }
      }
    },
  }
  
  dialog = renoise.app():show_custom_dialog("Window title", main_view)

end

main()

The Renoise Api currently missing a simple inputbox. You need to use the view builder. Made something like this, which is working fine:

local vb = renoise.ViewBuilder()
local bpm_selector = vb:valuebox { min = 30, max = 250, value = 120 }
local view = vb:vertical_aligner {
    margin = 10,
    vb:horizontal_aligner {
        spacing = 10,
        vb:vertical_aligner {
            vb:text { text = 'BPM:' },
            bpm_selector,
        },
    },
}

local res = renoise.app():show_custom_prompt(
        "Set sourc BPM",
        view,
        { 'Ok', 'Cancel' }
);
if res == 'Ok' then
end

Thx, @joule for your example.

I build a tool, which calculate the correct beatsync value, adds missing samples to the sample itself so it fits and enabled timestretching for it. Seems to working fine. Hope this will be improved with a simple bpm value box per sample in the sample settings in future Renoise version. Than it would be much simpler.