Control.redraw
solves flickering of listview dialog. Another problem: No matter how I adjust, I see the blue line in the right column, is it possible to make it not appear?
Of course it's a small problem, can ignore it. . .
function OnClick(clickData)
{
var strValue;
var strName;
var dlg = DOpus.Dlg;
dlg.title = "Directory Opus";
dlg.template = "dlgList";
dlg.detach = true;
dlg.Create();
dlg.Control("static").label = "Topic"; // Topic
dlg.Control("static2").label = "Notes"; // Notes
dlg.Control("static3").label = "D:\\Icons\\Find.png"; // Icon
dlg.Control("static4").label = "D:\\Icons\\Find.png"; // Icon
dlg.Control("static5").label = "D:\\Icons\\Clear.png"; // Clear
updateList(dlg, strName, strValue);
dlg.Show();
var lst = dlg.Control("list");
var col = lst.columns;
while (true) {
var msg = dlg.GetMsg();
if (!msg.result) break;
// Result
if(msg.event == "focus" || dlg.Control("btnOK").focus == true) {
var items = "";
for (i=0; i < lst.count; i ++) {
if (lst.GetItemAt(i).checked == 1) {
items += lst.GetItemAt(i).name;
items+= "\r\n";
}
}
}
// Right click list menu
if (msg.event == "rclick" && lst.focus == true) {
var dlgMenu = DOpus.Dlg;
if (lst.value.index > -1) {
//dlgMenu.choices = DOpus.Create.Vector("Edit...", "Delete", "-", "Select Variable", "Deselect Variable", "-", "Select All", "Select None", "-", "Copy Name", "Copy Value", "-", "Clear Filter", "Refresh");
dlgMenu.choices = DOpus.Create.Vector("OK", "Cancel");
//dlgMenu.menu = DOpus.Create.Vector(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
dlgMenu.menu = DOpus.Create.Vector(1, 1);
}
else {
//dlgMenu.choices = DOpus.Create.Vector("New...", "Delete", "-", "Select Variable", "Deselect Variable", "-", "Select All", "Select None", "-", "Copy Name", "Copy Value", "-", "Clear Filter", "Refresh");
dlgMenu.choices = DOpus.Create.Vector("OK", "Cancel");
dlgMenu.menu = DOpus.Create.Vector(1,1);
}
var menuReturn = dlgMenu.Show;
DOpus.Output(menuReturn);
}
// Filter
if (msg.event == "editchange" || msg.event == "click") {
updateList(dlg, strName, strValue);
}
}
// Output result
if(items != "" && dlg.result == 1) {
var array = items.split("\r\n");
for (i=0; array[i]; i ++) {
DOpus.Output(array[i]);
}
}
}
function updateList(dlg, strName, strValue) {
var lst = dlg.Control("list");
var col = lst.columns;
// Add columns
var vecOrder = col.GetDisplayOrder();
if (vecOrder.size < 1)
{
col.AddColumn("0:Name");
col.AddColumn("1:Index");
}
lst.redraw = false;
lst.RemoveItem(-1);
// List items
var text = "tag1, tag2, tag3, tag4, tag5, tag6, tag7, tag8, tag9, tag10, tag11, tag12, tag13, tag14, tag15, tag16, tag17, tag18, tag19, tag20, tag21, tag22, tag23, tag24, tag25, tag26, tag27, tag28, tag29, tag30, tag31, tag32, tag33, tag34, tag35";
var myArray = text.split(", "); // Seprator
var idx;
var ii = 0;
for(i = 0; myArray[i]; i++) {
strName = myArray[i];
var strRealName = myArray[i];
var strFilter = dlg.Control("editFilter").value; // Get filter value
strFilter = strFilter.toLowerCase();
if (strRealName.search(strFilter) == -1) {
continue;
}
idx = lst.AddItem(strName); // Add each item to list
lst.GetItemAt(idx).subitems(0) = i+1; // Add number to column 1 (Index)
ii++;
strRealName = "";
strFilter = "";
}
// Set the columns display order
if (true)
{
col.SetDisplayOrder(1,0);
}
// Resizing columns
//col.AutoSize();
col.GetColumnAt(1).width = String(i).length+25;
if (ii > 27)
{
col.GetColumnAt(0).width = 420-String(i).length;
}
else
{
col.GetColumnAt(0).width = 437-String(i).length;
}
lst.redraw = true;
}
==SCRIPT RESOURCES
<resources>
<resource name="dlgList" type="dialog">
<dialog fontsize="9" height="350" lang="english" resize="yes" title="Directory Opus" width="279">
<control halign="left" height="12" name="editFilter" resize="w" tip="Filter" type="edit" width="118" x="25" y="331" />
<control checkboxes="auto" fullrow="yes" height="287" name="list" noheader="yes" resize="wh" type="listview" viewmode="details" width="266" x="6" y="40" />
<control close="1" default="yes" height="12" name="btnOK" resize="xy" title="&OK" type="button" width="42" x="184" y="332" />
<control close="0" height="12" name="btnClose" resize="xy" title="C&ancel" type="button" width="42" x="229" y="332" />
<control halign="left" height="8" name="static" title="Topic" type="static" valign="top" width="236" x="33" y="7" />
<control halign="left" height="13" image="yes" name="static3" title="Static" type="static" valign="top" width="13" x="7" y="5" />
<control halign="left" height="13" image="yes" name="static4" title="Static" type="static" valign="top" width="13" x="8" y="330" />
<control halign="left" height="16" name="static2" title="Notes" type="static" valign="top" width="236" x="33" y="20" />
<control halign="left" height="5" name="static5" title="Static" type="static" valign="top" width="6" x="134" y="335" />
</dialog>
</resource>
</resources>