mIRC Home    About    Download    Register    News    Help

Print Thread
#273700 06/11/25 01:55 PM
Joined: Jul 2014
Posts: 307
TECO Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Jul 2014
Posts: 307
Hi Khaled,

Thank you for adding my suggestion.

However, I'd like to see if this is a bug or the intended behavior. When I have the "optional" condition for the edit box, and if I don't type anything and click OK, it's normal for the identifier $did(name,id) to return the text (optional).

Example:

[Linked Image from i.ibb.co]


Code
dialog version {
  title "Version"
  size -1 -1 306 155
  edit "Enter the server or nickname:", 1, 10 12 290 60
  edit "NOTE: If empty it will query the current server.", 2, 10 71 270 16, disable
  edit "", 3, 8 92 290 22, autohs optional
  button "&OK", 4, 142 124 76 23, ok
  button "&Cancel", 5, 223 124 76 23, cancel
}
on *:dialog:version:{
  if ($devent == sclick) && ($did == 4) { .raw version $did(3) }
}

Return: ".raw version (optional)"

The only solution I see is to put $remove($did(name,id),(optional)) in the command.

Example:
Code
.raw version $remove($did(3),(optional))



TECO
irc.PTirc.org (Co-Admin)
Joined: Dec 2002
Posts: 3,869
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 3,869
Thanks for your bug report. This is a bit more complicated than I anticipated. The (Optional) text has always depended on whether the editbox has focus or not. But in the case of custom dialogs, scripts can modify the content whether the editbox has focus or not. The only way around this that I can think of is that if a script tries to modify the editbox in any way, the (Optional) indicator will be automatically unset. And if a script tries to get the contents, it will return an empty value. This change will be in the next beta.

Joined: Jul 2014
Posts: 307
TECO Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Jul 2014
Posts: 307
Originally Posted by Khaled
Thanks for your bug report. This is a bit more complicated than I anticipated. The (Optional) text has always depended on whether the editbox has focus or not. But in the case of custom dialogs, scripts can modify the content whether the editbox has focus or not. The only way around this that I can think of is that if a script tries to modify the editbox in any way, the (Optional) indicator will be automatically unset. And if a script tries to get the contents, it will return an empty value. This change will be in the next beta.
Hi,
In my opinion, when I requested the addition of this condition, it was so that when the edit box is empty, the text (Optional) would appear, and when it is focused and the cursor is present, the text would disappear so that something could be typed. However, if you want to keep the edit box empty, the text (Optional) would still be displayed, but when you click OK, $did(name,id) would not return anything.


TECO
irc.PTirc.org (Co-Admin)
Joined: Dec 2002
Posts: 3,869
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 3,869
Yes, that sounds about right. Let's see how the next beta works out.

Joined: Jan 2012
Posts: 375
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 375
Client: mIRC v7.82.866 (beta)
OS: Windows 11 23H2 x64

    [Linked Image from i.ibb.co]
Code
alias dtest { dialog -m dtest dtest | did -f dtest 3 }
dialog dtest {
  title "Dialog ghost text"
  icon $mircexe,0
  option pixels
  size -1 -1 306 160
  edit "", 1, 8 12 290 60, multi optional "Enter some text here..."
  edit "NOTE: If the value is empty, ghost text will be displayed.", 2, 8 81 290 18, disable
  edit "Normal text", 3, 8 99 290 21, autohs optional "Ghost text..."
  button "&OK", 4, 142 130 76 23, ok
  button "&Cancel", 5, 223 130 76 23, cancel
}

Everything is almost good/perfect, except that when using custom ghost text, only the characters that were specified in quotes should be displayed, without modification. In this code example, I have specified a custom ghost text starting with a capital letter and without brackets, however, in the dialog box it displays with brackets and the first word starts with a lowercase letter.

So, it is assumed/expected that by default, when using the style optional, the ghost text in the dialog box should be displayed as (optional), and when adding custom text in quotes after the style, the text should be displayed in its original form, as the developer/designer of the script code wants to do, without additional brackets and in the specified letter case.


🌐 https://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Jan 2012
Posts: 375
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 375
It is not possible to add text after a style using a separate variable or identifier.
When trying to specify them between quotes, the dialog box displays the variable/identifier name instead of the text value.

    [Linked Image from i.ibb.co]
Code
alias dtest {
  set %gtext Enter some text here...
  dialog -m dtest dtest | did -f dtest 4
}
dialog dtest {
  title "Dialog ghost text"
  icon $mircexe,0
  option pixels
  size -1 -1 306 160
  edit "", 1, 8 12 290 60, multi optional %gtext
  text "NOTE: If the value is empty, ghost text will be displayed.", 2, 12 84 290 18, disable
  edit "", 3, 8 99 290 21, autohs optional " $gtext "
  button "&OK", 4, 142 130 76 23, ok default
  button "&Cancel", 5, 223 130 76 23, cancel
}
alias -l gtext { return Ghost text... }


🌐 https://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Jul 2014
Posts: 307
TECO Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Jul 2014
Posts: 307
Originally Posted by Khaled
Yes, that sounds about right. Let's see how the next beta works out.

Hi Khaled,

I tested it and it's working correctly now.

Epic's suggestion to add custom text seems great. If it's possible to add it, that would be perfect.

Thank you wink


TECO
irc.PTirc.org (Co-Admin)
Joined: Jul 2014
Posts: 307
TECO Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Jul 2014
Posts: 307
Hi Khaled,

I tested it and found a bug. For example, in the dialog below:

[Linked Image from i.ibb.co]

Code
alias test { dialog -m test test }

dialog test {
  title "Dialog ghost text"
  icon $mircexe,0
  option pixels
  size -1 -1 306 115
  edit "", 1, 8 12 290 60, multi optional "test"
  button "&OK", 4, 142 83 76 23, ok default
  button "&Cancel", 5, 223 83 76 23, cancel
}
on *:dialog:test:*:*:{
  if ($devent == init) { did -f $dname 4 }
  elseif ($devent == sclick) {
    if ($did == 4) { echo -sg -- $did(1) }
  }
}

But if, for example, I type the same text from the ghost text (test) into the edit box, it doesn't return anything in the identifier $did(1)

[Linked Image from i.ibb.co]

However, I wanted to know one thing. Why are parentheses necessary for this to work, since they suggest that this feature will stop working if someone types the same text for real?

Hug wink


TECO
irc.PTirc.org (Co-Admin)
Joined: Dec 2002
Posts: 3,869
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 3,869
Thanks for the feedback. The behaviours you describe are how the (optional) feature has always worked across all dialogs. The custom dialogs are simply using the existing functions for this.

I have had to make more changes to the custom dialog optional keyword parser as there was an issue with the order in which it was being parsed in the custom dialog code. At this point, I have decided to remove this feature for now and revert to the 7.82 custom dialog code, as it still needs more testing and will delay the release that was planned this week. I will add it back in a future beta cycle.


Link Copied to Clipboard