Hello,
I'm trying to make a confirmation dialogue on a button pressed inside a
popup. I have distilled the code from my application into the following:
require 'iuplua'
require 'iupluacontrols'
testbutton = iup.button{title = "push me to show item", fontsize = "20"}
content = iup.hbox{testbutton}
mainwindow = iup.dialog{content}
function testbutton:action()
print(iup.MainLoopLevel())
reallybutton = iup.button{title="push me to delete this item",
fontsize="20"}
pane = iup.hbox{reallybutton}
pop = iup.dialog{pane; parentdialog = mainwindow}
function reallybutton:action()
print(iup.MainLoopLevel())
anotherbutton = iup.button{title="ok", fontsize="20"}
cancelbutton = iup.button{title="cancel", fontsize="20"}
panel = iup.hbox{anotherbutton, cancelbutton}
pop2 = iup.dialog{panel; parentdialog = pop}
function anotherbutton:action()
pop2:destroy()
pop:destroy()
end
function cancelbutton:action()
pop2:destroy()
end
pop2:popup()
end
pop:popup()
end
mainwindow:showxy()
if(iup.MainLoopLevel()==0) then
iup.MainLoop()
end
This simple program works as I would like: First button pops up a window to
show an item (here nothing), and in that window there is a delete button.
If the delete button is pressed, a confirmation dialogue pops up with ok or
cancel. Cancel closes one popup (returns to the item, here nothing) where
ok closes both popups (and deletes the item, but in this demo code that
doesn't happen of course).
The problem I'm having is that this causes the application to hang when the
last window is closed, as you may see. I am printing out the
mainlooplevel--this seems to be the culprit. I know that calls to popup
increment the loop level, but they are not being decremented properly when
I close the popups. I am unsure how to do this correctly. Can anyone point
me in the right direction? I feel I am missing something.
I have tried calling iup.ExitLoop() and returning iup.CLOSE in various
places (destroy/close callbacks on popups, and in the callback where I
destroy both popups) but this only keeps the mainloop levels lower, it
still does not close all of the loops.
Thanks,
Jesse
------------------------------------------------------------------------------
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users