mIRC Home    About    Download    Register    News    Help

Print Thread
#228682 07/01/11 12:35 AM
Joined: Jul 2004
Posts: 59
L
Babel fish
OP Offline
Babel fish
L
Joined: Jul 2004
Posts: 59
Is there an Identifier / event that can tell when a user presses the Enter key in a Dialog window as the default function is to close the dialog Is there a way to halt this and preform another function leaving the dialog open.

Last edited by LittleJohn; 07/01/11 12:35 AM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
You can set focus on an id in a dialog using /did -f so that Enter will affect that ID instead of your OK button (OK closes the dialog). You can also set a different button as default when creating the dialog so that the default button isn't the OK button.


Invision Support
#Invision on irc.irchighway.net
Joined: Jul 2004
Posts: 59
L
Babel fish
OP Offline
Babel fish
L
Joined: Jul 2004
Posts: 59
I actually tried this but it doesn't work, setting the focus has no effect on the dialog closing when the user presses the enter key. Below is a simplified sample of the code I am using as you can see I set the focus on the Look-up button but if the user presses their enter key the dialog closes.

Code:
alias WTFB { 
  dialog -m WTFB WTFB
}

dialog WTFB {
  title "TEST"
  size -1 -1 163 175
  option dbu
  combo 1, 4 41 91 132, size
  button "Look Up", 2, 96 41 62 12
  text "Select the Word from the word list.", 3, 101 58 57 78
  text "Choose a word", 4, 5 31 45 8
  button "Exit", 5, 110 152 37 12, ok
  button "A", 10, 21 8 9 9
  button "B", 16, 30 8 9 9
  button "C", 17, 39 8 9 9
  button "D", 18, 48 8 9 9
  button "E", 19, 57 8 9 9
  button "F", 20, 66 8 9 9
  button "G", 21, 75 8 9 9
  button "H", 22, 84 8 9 9
  button "I", 23, 93 8 9 9
  button "J", 24, 102 8 9 9
  button "K", 25, 111 8 9 9
  button "L", 26, 120 8 9 9
  button "M", 27, 129 8 9 9
  button "N", 28, 21 20 9 9
  button "O", 29, 30 20 9 9
  button "P", 30, 39 20 9 9
  button "Q", 31, 48 20 9 9
  button "R", 32, 57 20 9 9
  button "S", 33, 66 20 9 9
  button "T", 34, 75 20 9 9
  button "U", 35, 84 20 9 9
  button "V", 36, 93 20 9 9
  button "W", 37, 102 20 9 9
  button "XYZ", 38, 111 20 27 9
  text "Choose First Letter", 41, 5 0 60 8
}

on *:dialog:WTFB:SCLICK:*:{
  if ($did == 10) { set %wtb_flet A  | /echo -a test }
  elseif ($did == 16) { set %wtb_flet B  | /echo -a Test }
  elseif ($did == 17) { set %wtb_flet C  | /echo -a Test }
  elseif ($did == 18) { set %wtb_flet D  | /echo -a Test }
  elseif ($did == 19) { set %wtb_flet E  | /echo -a Test }
  elseif ($did == 20) { set %wtb_flet F  | /echo -a Test }
  elseif ($did == 21) { set %wtb_flet G  | /echo -a Test }
  elseif ($did == 22) { set %wtb_flet H  | /echo -a Test }
  elseif ($did == 23) { set %wtb_flet I  | /echo -a Test }
  elseif ($did == 24) { set %wtb_flet J  | /echo -a Test }
  elseif ($did == 25) { set %wtb_flet K  | /echo -a Test }
  elseif ($did == 26) { set %wtb_flet L  | /echo -a Test }
  elseif ($did == 27) { set %wtb_flet M  | /echo -a Test }
  elseif ($did == 28) { set %wtb_flet N  | /echo -a Test }
  elseif ($did == 29) { set %wtb_flet O | /echo -a Test }
  elseif ($did == 30) { set %wtb_flet P | /echo -a Test }
  elseif ($did == 31) { set %wtb_flet Q | /echo -a Test }
  elseif ($did == 32) { set %wtb_flet R | /echo -a Test }
  elseif ($did == 33) { set %wtb_flet S | /echo -a Test }
  elseif ($did == 34) { set %wtb_flet T | /echo -a Test }
  elseif ($did == 35) { set %wtb_flet U | /echo -a Test }
  elseif ($did == 36) { set %wtb_flet V | /echo -a Test }
  elseif ($did == 37) { set %wtb_flet W | /echo -a Test }
  elseif ($did == 38) { set %wtb_flet XYZ | /echo -a Test }

}

on *:dialog:WTFB:init:0: {
  did -f $dname 2
}

Last edited by LittleJohn; 11/01/11 02:06 AM.
Joined: Jul 2004
Posts: 59
L
Babel fish
OP Offline
Babel fish
L
Joined: Jul 2004
Posts: 59
After much playing around I have solved this issue for anyone who might come across this, indeed the dialog will close if the focus is set to the button in my example I did not include all the code but what this code dose is allow a user to look up a word with data from a database of aprox 30000 words thus the A-z buttons. Anyway the reason the close is you need to have something for the button to do so your identifier cant be $null. When I gave it something to look up Wallah no more close. Thank you too all the helpers here and happy coding.

Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
There doesn't appear to be a way to capture that in a normal dialog.

Just an idea!
I haven't tested this, but Im thinking there is a possibility you can use the sclick event of your 'Ok' button to check before it closes the dialog.

on *:dialog:wtfb:sclick:5:halt

Will the dialog still close if it's halted like this? If halt does stop it from closing then the idea would be to check to make sure your requirements are met, if not halt, otherwise let the dialog close.

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
To prevent the close-on-enter behaviour, remove the "ok" style from ID "5" ("exit" button) (just add a dialog-closing command for sclick on "5").
To prevent any triggering of the currently focused ID with the ENTER key, I added a hidden button "100" that gets focus on init and on sclick.
If your letter-IDs would be all in order (I changed "10" to "15"), you could save a lot of code with a short calculation on sclick.
Code:
alias WTFB {  dialog -m WTFB WTFB }

dialog WTFB {
  title "TEST"
  size -1 -1 163 175
  option dbu
  combo 1, 4 41 91 132, size
  button "Look Up", 2, 96 41 62 12
  text "Select the Word from the word list.", 3, 101 58 57 78
  text "Choose a word", 4, 5 31 45 8
  button "Exit", 5, 110 152 37 12
  button "A", 15, 21 8 9 9
  button "B", 16, 30 8 9 9
  button "C", 17, 39 8 9 9
  button "D", 18, 48 8 9 9
  button "E", 19, 57 8 9 9
  button "F", 20, 66 8 9 9
  button "G", 21, 75 8 9 9
  button "H", 22, 84 8 9 9
  button "I", 23, 93 8 9 9
  button "J", 24, 102 8 9 9
  button "K", 25, 111 8 9 9
  button "L", 26, 120 8 9 9
  button "M", 27, 129 8 9 9
  button "N", 28, 21 20 9 9
  button "O", 29, 30 20 9 9
  button "P", 30, 39 20 9 9
  button "Q", 31, 48 20 9 9
  button "R", 32, 57 20 9 9
  button "S", 33, 66 20 9 9
  button "T", 34, 75 20 9 9
  button "U", 35, 84 20 9 9
  button "V", 36, 93 20 9 9
  button "W", 37, 102 20 9 9
  button "XYZ", 38, 111 20 27 9
  text "Choose First Letter", 41, 5 0 60 8
  button "", 100, 100 100 1 1, hide
}

on *:dialog:WTFB:*:*:{
  if ($devent == init) { did -f $dname 100 }
  elseif ($devent == sclick) {
    did -f $dname 100
    if ($did isnum 15-37) {
      var %letter = $chr($calc($did + 50))
      set %wtb_flet %letter
      echo -a test: click on ID $did = %letter
    }
    elseif ($did == 38) {
      set %wtb_flet XYZ
      echo -a test: click on ID $did = XYZ }
  }
}


Link Copied to Clipboard