I'm stumped once again ^^
While working with a detached GUI in a JScript button, I can't seem to get a ListView's column's AutoSize to work.
var dlg = DOpus.Dlg();
dlg.template = "RenameGUI";
dlg.detach = true;
dlg.Show();
dlg.Control("fileList").AddItem("test");
log(dlg.Control("fileList").columns); // <- recognizes Control.columns as an object
dlg.Control("fileList").columns.InsertColumn("Toast", 1);
log("works so far");
dlg.Control("fileList").columns.AutoSize(); // <- throws 0x8000ffff
Throws
A method was called unexpectedly (0x8000ffff)
And I know I'm using .AutoSize()
in another script.
What on earth is going on here? O.o
Edit:
This only seems to reproduce in an eval()
.
Because I'm using a wrapper function that allows me to write the actual script I want without having to manually set up everything (declare standard variables, set up checks, functions and extensions, etc), my scripts run through a custom command that eval
s the script source reading it from a file.
Here I've created a button script that illustrates the issue: Toggle asEval
to trigger the error.
var tab;
function OnClick(data)
{
tab = data.func.sourcetab;
var asEval = false; // <- toggle to switch between eval and direct interpretation
if(asEval){
eval("var dlg = DOpus.Dlg();\
dlg.window = tab;\
dlg.template = 'RenameGUI';\
dlg.detach = true;\
\
dlg.Show();\
\
dlg.Control('fileList').AddItem('test');\
dlg.Control('fileList').columns.InsertColumn('Toast', 1);\
DOpus.Output('works so far');\
dlg.Control('fileList').columns.AutoSize();\
while (true) {\
var Msg = dlg.GetMsg();\
if(Msg.result !== false){\
}\
else{\
break;\
}\
}");
}else{
//////////////// VS //////////////////////
var dlg = DOpus.Dlg();
dlg.window = tab;
dlg.template = 'RenameGUI';
dlg.detach = true;
dlg.Show();
dlg.Control('fileList').AddItem('test');
dlg.Control('fileList').columns.InsertColumn('Toast', 1);
DOpus.Output('works so far');
dlg.Control('fileList').columns.AutoSize();
DOpus.Output('success');
while (true) {
var Msg = dlg.GetMsg();
if(Msg.result !== false){
}
else{
break;
}
}
}
}
GUI:
<resources>
<resource name="RenameGUI" type="dialog">
<dialog fontsize="8" height="252" lang="" resize="yes" width="690">
<control height="174" name="fileList" nosel="yes" resize="wh" type="listview" viewmode="details" width="678" x="6" y="54">
<columns>
<item text="Old Name" />
<item text="New Name" />
</columns>
</control>
<control close="1" default="yes" height="14" name="bOK" resize="xy" title="OK" type="button" width="50" x="636" y="234" />
</dialog>
</resource>
</resources>
I've done a bunch of scripting within eval()
s, but this is the first time I've noticed something not working within one that would without.
What gives? O.o
It's especially strange since columns.InsertColumn
works, and everything before it.
(Yes, I know, eval
is evil, but until DOpus allows users to write and conveniently use function libraries and wrappers for button scripts, it's just too useful not to use)