The problem is that you are destroying the dialog during the callback. You
MUST return iup.IGNORE in this case. And I don't think you can destroy the
parent dialog also inside that callback.

So attached is a more safe version of your script where mainlooplevel is
correctly maintained.

Best,
Scuri


On Fri, Nov 7, 2014 at 1:29 PM, Jesse WMC <[email protected]> wrote:

> 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
>
>

Attachment: mainloop.lua
Description: Binary data

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users

Reply via email to