@Michael
code:
var dlg = moi.ui.createDialog( '<html><body class="DialogBody"><div>testing...</div><moi:DialogClose/></body></html>', 'resizable,defaultWidth:350,defaultHeight:200' );
while ( dlg.waitForEvent() ){
if ( dlg.event == "display" )
break;
}
dlg.window.move( 10, 10 );
1. I was wondering if you can share a bit more info on what's going on behind the scene. I'm trying to write my plugin with more asynchronous code, promises, and callbacks, and attempting to use `createDialog` for something it was not meant for, ie: panels and toolbars.
I can get `resize()` to work but not `move()`...
After doing some testing I notice (speculating) the following:
- The HTML view (QT WebView) is loaded and all of the rendering and DOM events are completed, prior to the dialog's "display" event. You can manipulate DOM/window without issues at this point.
- I'm speculating that the window/QT layout is modified after the WebView's triggered the load completed, something along the lines of `restoreGeometry`, `restoreState`. The window is centered (relative to the main) (as an expected behavior of a dialog) and window dimensions are restored.
- After that, the `display` event is triggered.
- You can handle the "Esc" in javascript, it always dismisses the dialog.
2. I have a couple of wishes/ramblings!
It would be cool if you add a couple of signals to your QTObjects, that would make this type of interaction more event-driven.
In createDialog() there could be additional window parameters to control its behavior, or maybe a new openWindow() function like
code:
var dialog = moi.ui.openWindow(html, 'resizeable,defaultWidth:380,defaultHeight:420,isModal:true,isCentered:true,style:Dialog,title:My Dialog', moi.ui.mainWindow );
In this example, `isModal ` means that it blocks interaction with MoI until it is dismissed (Qt::ApplicationModal).
Style control the layout and window type like Qt::Window, Qt::Dialog, Qt::Tool, Qt::Popup, etc. Allowing the FramelessWindowHint would be cool to do HUDs and overlays.
===EDITS ====
More observations
`defaultWidth` and `defaultHeight` only work the first time the dialog is used, subsequent calls to the same code/command ignore these values. They work if the actual HTML contents or the URL changes from the previous call.
re
>> I have also got it set up for the next beta so that if a script calls .move() or .resize() on a window before it has finished loading it will record the given position or size and apply it after it has loaded.
I actually did that, I tried two approaches, one would concatenate JS code that would be executed after the `display` event, sort of like a jquery "ready" function. The other would store properties in the window object with a flag to resize/move. Among others, the object would have things like minWidth and minHeight to limit `resize` (you can not change the size by code unless the window has resizable property).
The `resize()` works, but `move()` never worked.