Jump to content


Photo

Attaching notifiers to buttons in show_custom_prompt ?


  • Please log in to reply
2 replies to this topic

#1 redlaserbm

redlaserbm

    New Member

  • Normal Members
  • Pip
  • 2 posts

Posted 26 June 2018 - 04:07

It is possible to show custom views and attach notifiers to buttons (the ones you call with say vb:button{ "This is a placeholder!" })  in those views, but what about for the bottom buttons in a custom prompt created using renoise.app():show_custom_prompt? Suppose for example I call 

renoise.app():show_custom_prompt(title, content_view, {"Button1", "Button2"})

How can I make it so button1 does something when I click on it and button2 does something (different) when I click on it? 

 

Best,

Laser



#2 joule

joule

    Guruh Motha Fakka is Levitating and Knows Everything About Renoise Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 1750 posts
  • Gender:Not Telling
  • Location:Sweden
  • Interests:music, philosophy, engineering

Posted 26 June 2018 - 09:48

function main()
  
  local vb = renoise.ViewBuilder()
  
  local my_view = vb:row {
    vb:text {
      text = "My content"
    }
  }
  
  local modal_popup = renoise.app():show_custom_prompt("My window", my_view, { "Abort", "OK" })

  -- script resumes here once a button is pressed
  if modal_popup == "Abort" then
    print("Abort button was pressed")
  elseif modal_popup == "OK" then
    print("OK button was pressed")
  else
    print("The window was closed")
  end
  
end 

main()

NB1. the close [x] button will return the text "Cancel".

 

NB2. It's a lot more common to use non modal dialogs (:show_custom_dialog). The modal dialog will steal all focus, which can be quite annoying imo.



#3 redlaserbm

redlaserbm

    New Member

  • Normal Members
  • Pip
  • 2 posts

Posted 28 June 2018 - 06:18

Nice! Thank you for this help. I'll reply again if I run into any further trouble on this topic.