Possible To Close Dialog On Opening A New Song?

Is it possible to close a custom dialog on opening a new song?

renoise.app():show_custom_dialog( WOOT )  
renoise.tool().app_release_document_observable:add_notifier(CLOSE WOOT)  

I would like to thank may parents, my manager and Bantai for enabling the creation of this tool…

This just needed a slight mod to stop an error firing, depending on circumstance.

local function closer(d)   
if d and d.visible then  

cheers again, seems to work great.

Heres an alternative simplified version without the “context magic”, based on Bantai’s version. Maybe easier to understand and handle in this case:

local my_dialog = nil  
local function open_dialog()  
 -- only show one dialog at the same time  
 if (my_dialog and my_dialog.visible) then  
 -- create a new dialog  
 local vb = renoise.ViewBuilder()   
 my_dialog = renoise.app():show_custom_dialog("My Dialog",   
 text = "Bla blah, bla blah. Meh."  
local function close_dialog()   
 -- close the dialog, if its open  
 if (my_dialog and my_dialog.visible) then  
 my_dialog = nil  
-- auto close the open dialog when the song gets exchanged, released  
 name = "Main Menu:Tools:DialogCloser",  
 invoke = open_dialog   

Is it possible to get the close button at the top left to make a function call? It would need to call close_dialog() where I have added some :remove_child()'s that are necessary to avoid this error

std::logic_error: 'ViewBuilder: trying to add a view which already was added, probably into a different parent view.'  
stack traceback:  
 [C]: in function 'add_child'  
 ./gui.lua:195: in function 'dialog_create'  
 ./gui.lua:221: in function 'show_dialog'  
 main.lua:66: in function <64><br>

unless there's some kind of other way to get rid of these children without removing them explicitly?<br>
Ok, quick hack here for anyone who needs to do the same<br>

function show_dialog()<br>
	if dialog and dialog.visible then<br>
	if vb then<br>
function remove_vb()<br>
	vb.views.group_one = nil<br>
	vb.views.group_two = nil<br>
	vb.views.group_three = nil<br>
	vb = nil<br>
function close_dialog()<br>
	if dialog and dialog.visible then<br>
	  dialog = nil<br>


Should be easily solved by !always! recreating the vb when recreating the dialog.

if dialog and dialog.visible then  
-- when reaching this, the dialog never was created before or was closed  


Is it possible to have a notifier on the event, if someone closes a (non-modal) dialog by clicking on the “x” or pressing the key “escape”?
I would like to change some buttons on the Launchpad if the user closes a dialog. Using the method above will not work well, because I would have to check on every next (unpredictible) event if the dialog was closed.

Buy them a Sony Playstation 3 :P

Another question i Have, is it possible to determine the Position of a new opened dialog? It seems the dialog is centered by default. It would be nice to have two screens next to each other.

Was a long wish for me as well, that’s why embedded the note-matrix into the epic arpeggiator tool. It used to be a separate window but it always popped up in front of the main arpeggiator dialog. That is currently the trick to do it. (Pop it out of any side by unhiding several objects and remove it by toggling the visibility parameter again)

Great trick, thanks! :)
That makes the solution of the “notify on close-dialog” problem redundant.

Nevertheless both things would be usable though.

You can also try emulate “Tabs” using the Switch button object and then make up several designs on the same spot.
Simply just hide and unhide the objects depending on the state of the switch button.

This question pops up again.
I also can not check if the main window of the tool was closed or not, if the user clicks the “x” in the main window.
I have a pattern change notifier, and regardless if the main window called ‘maingui’ is closed or not, vb.views[‘maingui’].visible is always true. Is there a way?
I am doing some time consuming tasks on patternchange and they need not to be done if the main window of the tool is not opened.

I used a trick for ther IRC client to figure out if a window was still open and even checked whether a connection was made (and is still open):

--If status window is closed, drop connection  
--yet if status window was not raised, then drop connection upon closing  
--the chat dialog. (if not switch_channel status is up)  
 if (not irc_dialog or not irc_dialog.visible) and status_dialog_mode then  

But i think “if (not dialog or not dialog.visible) then” should suffice.

Thanks a lot, that worked :)