# Using Custom Dialogs

**URL:** <https://resource.dopus.com/t/using-custom-dialogs/26381>\
**Category:** Help & Support\
**Created:** [July 16, 2017, 1:35am UTC](https://resource.dopus.com/t/using-custom-dialogs/26381 "2017-07-16T01:35:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![wowbagger](https://resource.dopus.com/user_avatar/resource.dopus.com/wowbagger/32/25880_2.png) [@wowbagger](https://resource.dopus.com/u/wowbagger)\
**Post date:** [July 16, 2017, 1:35am UTC](https://resource.dopus.com/t/using-custom-dialogs/26381/1 "2017-07-16T01:35:53Z")

</div>

Looking for feedback regarding the use of custom dialogs.

I have recently started looking at using the CustomDialogs. My first dialog was rather simple. It allows the user to input values for an external tool [enfuse buttons](https://resource.dopus.com/t/enfuse-buttons-v1-5/18485).

- Replacing this  
 ![](https://resource.dopus.com/uploads/default/original/3X/e/5/e5b828550f748491c1b93d6c065ab0c56ffdc9cc.jpg)
- with this  
 ![](https://resource.dopus.com/uploads/default/original/3X/6/3/630200ba667a203dd6cf583040e4263710e6b3b7.jpg)

This is how I implemented it. Does this seem best practice, do you see any issues here? Full script in this thread [enfuse buttons](https://resource.dopus.com/t/enfuse-buttons-v1-5/18485).

```auto
    var dlg = DOpus.Dlg;
    dlg.window = funcData.func.sourcetab;
    dlg.template = "dialogEnfuse";
    dlg.detach = true;
    
    dlg.Show();
  
    dlg.Control("comboPresets").AddItem("ExposureStackParams");
    dlg.Control("comboPresets").AddItem("FocusStackParams");
    dlg.Control("comboPresets").AddItem("CustomDefaultParams");
    dlg.Control("comboPresets").AddItem("UserDefaultParams");
  
    var closeDialog;
    while (!closeDialog) {
      var msg = dlg.GetMsg();
      if (!msg.result) break;
      
      LogMessage("Msg: " + msg.control + " value: " + msg.value + " event:" + msg.event);

      switch (msg.control) {
        case "comboPresets" :
           PresetSelected(dlg, msg);
           break;
        case "buttonOK" :
           params = DialogClosed(dlg, msg);
           closeDialog = true;
           break;
      } 
    }

    if(!(params))
    {
      LogMessage("Dialog canceled");
      return;
    }

    LogMessage("Return code = " + dlg.result);
    LogMessage("Return value = " + params);

function PresetSelected(dlg, msg) {
  LogMessage("PresetSelected: " + msg.control +":"+ msg.event);
 
  if(msg.control != "comboPresets" || msg.event != "selchange")
    return;
    
  var dialogParams;
  switch (msg.value) {
    case "ExposureStackParams" :
      dialogParams = Script.config.ExposureStackParams;
      break;
    case "FocusStackParams" :
      dialogParams = Script.config.FocusStackParams;
      break;
    case "CustomDefaultParams" :
      dialogParams = Script.config.CustomDefaultParams;
      break;
    case "UserDefaultParams" :
      dialogParams = Script.config.UserDefaultParams;
      break;
  } 

  if(!(dialogParams))
  {
    dialogParams= "--exposure-weight=--saturation-weight=--contrast-weight=--exposure-mu=--soft-mask"
  }

  if(dialogParams)
  {
    var splitParams = dialogParams.split("--");
    for (var i = 0; i < splitParams.length; i++) {
      DOpus.Output(splitParams[i]);
      var splitParam = splitParams[i].split("=");
      switch (splitParam[0]) {
        case "exposure-weight" :
          dlg.Control("exposure").value = splitParam[1];
          break;
        case "saturation-weight" :
          dlg.Control("saturation").value = splitParam[1];
          break;
        case "contrast-weight" :
          dlg.Control("contrast").value = splitParam[1];
          break;
        case "exposure-mu" :
          dlg.Control("gaussion").value = splitParam[1];
          break;
        case "soft-mask" :
          dlg.Control("mask").value = 0;
          break;
        case "hard-mask" :
          dlg.Control("mask").value = 1;
          break;
      } 
    }
  }
}

function DialogClosed(dlg, msg) {
  var result = BuildCommand("exposure-weight", dlg.Control("exposure").value)
             + BuildCommand("saturation-weight", dlg.Control("saturation").value)
             + BuildCommand("contrast-weight", dlg.Control("contrast").value)
             + BuildCommand("exposure-mu", dlg.Control("gaussion").value)
             + ((dlg.Control("mask").value == 1) ? " --hard-mask" : " --soft-mask");
  LogMessage("selected: " + result + " || " + dlg.Control("mask").value);
  return result;
}
```

My next dialog will be to create a UI for editing custom columns specific to a script. I would like to have something similar to the rename dialog. Where down the left is a list of the columns and to the right are the settings for them. This relates to this thread [configuring dynamic-columns](https://resource.dopus.com/t/support-for-dynamic-column-settings/26344).

Feedback appreciated

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [July 16, 2017, 2:09am UTC](https://resource.dopus.com/t/using-custom-dialogs/26381/2 "2017-07-16T02:09:23Z")

</div>

The code looks fine from a quick look through it.

---

<div class="post-metadata">

**Author:** ![wowbagger](https://resource.dopus.com/user_avatar/resource.dopus.com/wowbagger/32/25880_2.png) [@wowbagger](https://resource.dopus.com/u/wowbagger)\
**Post date:** [July 16, 2017, 8:02am UTC](https://resource.dopus.com/t/using-custom-dialogs/26381/3 "2017-07-16T08:02:06Z")

</div>

Couple of things I cant get working. (different script to above).

**add icon to DialogListItem**  
I was not able to set the icon of a [DialogListItem](https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Scripting/DialogListItem.htm).  
I tried this:

```auto
    var lstItem = dlg.Control("configurationsList");
    for(var i = 0; i < localConfig.tools.length; ++i) {
      var location = lstItem.AddItem(localConfig.tools[i].product);
      var item = lstItem.GetItemAt(location);
      //item.icon = localConfig.tools[i].icon
      //item.icon = "ExternalCompare:Araxis"
      //item.icon = ".txt";
    }
```

Regardless I get an error of **A method was called unexpectedly (0x8000ffff)**. I want to set it to the icon that I provide in the buttons I.E. _ExternalCompare:Araxis_.

**update static text**  
I wanted to update the value of a [Static Text](https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Scripting/Static_Text_Properties.htm) object.  
I tried this

```auto
dlg.Control("myStaticTextName").value = "the updated text"
```

Didnt error but does not work.

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [July 16, 2017, 11:05am UTC](https://resource.dopus.com/t/using-custom-dialogs/26381/4 "2017-07-16T11:05:48Z")

</div>

Each new question would be better as a separate thread, so people who run into the same problem can find the answer more easily.

Please also post the full script(s). The code fragment looks OK to me but I can't try it out or see which types of dialog resources it is acting on without the full thing.

---

<div class="post-metadata">

**Author:** ![belfong](https://resource.dopus.com/user_avatar/resource.dopus.com/belfong/32/59704_2.png) [@belfong](https://resource.dopus.com/u/belfong)\
**Post date:** [July 17, 2017, 12:27am UTC](https://resource.dopus.com/t/using-custom-dialogs/26381/5 "2017-07-17T00:27:00Z")

</div>

> [@Leo](#):
>
> Each new question would be better as a separate thread, so people who run into the same problem can find the answer more easily.

As admin, you can split this conversation into a separate thread - just so you know this useful feature of Discourse.

---

<div class="post-metadata">

**Author:** ![wowbagger](https://resource.dopus.com/user_avatar/resource.dopus.com/wowbagger/32/25880_2.png) [@wowbagger](https://resource.dopus.com/u/wowbagger)\
**Post date:** [July 20, 2017, 10:22am UTC](https://resource.dopus.com/t/using-custom-dialogs/26381/6 "2017-07-20T10:22:08Z")

</div>

> [@Leo](#):
>
> Each new question would be better as a separate thread, so people who run into the same problem can find the answer more easily.

Will do, I have created a post specific to adding a images DialogListItem.

> [@Setting icon on dialog list](https://resource.dopus.com/t/setting-icon-on-dialog-list/26386):
>
> I have created a dialog that contains a listbox, I would like to display icons in the list box from my IconSet. I cant work out how to get that to work. This is the dialog. dialog config \<control height="240" name="configurationsList" t…

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [July 20, 2017, 11:39am UTC](https://resource.dopus.com/t/using-custom-dialogs/26381/7 "2017-07-20T11:39:22Z")

</div>

> [@belfong](#):
>
> As admin, you can split this conversation into a separate thread - just so you know this useful feature of Discourse.

I am well aware of that, thank you. But you cannot split a single post in two very easily, and you cannot make extra details like the full script appear from thin air. 🙂
