lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


  Hi,


  You have two different problems. They have separate solutions. 


> I noticed that there is also a PARENTDIALOG attribute at least for IUP dialog objects.  But I can’t work out how to use this either.  Is it assuming that the parent dialog is another IUP dialog object? 


  Yes, in this case the attribute points to the name of another IUP dialog.


 

> I tried using IUP dialogs and setting the NATIVEPARENT attribute, having setup  the value of my application’s main windows HWND as a (global) integer within the Lua environment.  None of the ways I tried of setting the NATIVEPARENT attribute worked, and I’m not sure if that is what I’m supposed to be doing anyway.


  That's the solution I would give to you regarding the IUP dialogs to be in front of your native dialogs (not related to the modal problem). So probably setting the attribute failed. Since this attribute must be a pointer to the HWND, it must be an usedata in Lua. And this will not work for a regular "ih.nativeparent = hWnd" call. You will have to do it using "iup.SetAttribute(ih, "NATIVEPARENT", hWnd)". 

 

 

> I also tried using the SIMULATEMODAL attribute.  Like PARENTDIALOG that only seems applicable to dialog objects, and not ‘Alarm’ or ‘GetParam’.  But in any case, I couldn’t get it to work either. 


  IupAlarm and IupGetParam internally use IupDialogs, but both are functions that create and show pre-defined dialogs. Usually they are configured through a callback (IupGetParam) or global attributes (IupAlarm). Although they are not NATIVEPARENT friendly. It will be not simple to use NATIVEPARENT with them, but it is possible, at least for IupGetParam.


  SIMULATEMODAL will automatically disable other IupDialogs so IupShow can be used. IupPopup does the same. So in both cases, they will work for IupDialogs only. 


  So if you want IUP dialogs to be "modal" regarding the native dialogs too you will have to manually disable other native dialogs before running the script, or at least before running a script that needs that. We have two internal global callbacks that can help, they are called before and after a modal dialog is displayed, they are GLOBALENTERMODAL_CB and GLOBALLEAVEMODAL_CB. They are not available in Lua. They could be implemented in the C part of your application. 


Best,

Scuri



Em ter, 11 de jun de 2019 às 13:41, Simon Orde <SimonOrde@family-historian.co.uk> escreveu:

Hi

 

I use LUA as an embedded scripting language to support user-created plugins within my Windows Visual C++ application.  I want my users to be able to display IUP windows and dialogs within a LUA plugin.   My application has windows and dialogs of its own.  If I run a Lua plugin that displays any kind of dialog (e.g. by using iup.GetParam or iup.Alarm say), the IUP Help for both GetParam and Alarm says that they will display a “modal dialog”.  However, the dialog that is displayed is not modal – or not at least with respect to my other windows and dialogs.   All the existing windows and dialogs within my application continue to be accessible and enabled, and if I click on any one of them, the IUP dialog will disappear behind my application window.  The only way I can prevent this is to disable all my application windows and dialogs before running the plugin, and re-enable them afterwards.  However, that is not a good solution for me for a number of reasons – not least that it doesn’t fully prevent the IUP dialog accidentally ending up behind my application windows.  It just makes it less likely to happen by the user clicking on one of my windows.

 

I would like to find some way of making IUP dialogs properly modal with respect to my other application windows.  I would also like to find some way of supporting IUP windows that are not modal, but nevertheless float in front of my other application windows – and without having to make them always-on-top type of windows.

 

I tried using IUP dialogs and setting the NATIVEPARENT attribute, having setup  the value of my application’s main windows HWND as a (global) integer within the Lua environment.  None of the ways I tried of setting the NATIVEPARENT attribute worked, and I’m not sure if that is what I’m supposed to be doing anyway.

 

I noticed that there is also a PARENTDIALOG attribute at least for IUP dialog objects.  But I can’t work out how to use this either.  Is it assuming that the parent dialog is another IUP dialog object?

 

I also tried using the SIMULATEMODAL attribute.  Like PARENTDIALOG that only seems applicable to dialog objects, and not ‘Alarm’ or ‘GetParam’.  But in any case, I couldn’t get it to work either.  E.g. I tried this:

 

require( "iuplua" )

 

vbox = iup.vbox { iup.label {title="Label"}, iup.button { title="Test" } }

dlg = iup.dialog{vbox; title="Dialog", SIMULATEMODAL=true}

dlg:show()

 

if (iup.MainLoopLevel()==0) then

  iup.MainLoop()

end

 

That doesn’t work.

 

All help with this very much appreciated – especially actually lua code examples!  Thank you.

 

Simon