mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jul 2003
Posts: 77
B
Babel fish
OP Offline
Babel fish
B
Joined: Jul 2003
Posts: 77
I never understood why number wasnt an edit box option so that the editbox had the ES_NUMBER style and was only limited to number entries

This would not be a hard thing to add have i just missed it over the years? if not i definitly think ti should be added as a style for obvious reasons it is very helpful...

and i know it can be done with a dll but it shouldnt have to be... not this at least


hmmm signed by me
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
For now you can use the following
Code:
on *:dialog:*:edit:*:{
  var %text
  if ($regsub($did($did),/\D+/g,,%text)) { did -ra $dname $did %text }
}


New username: hixxy
Joined: Jul 2003
Posts: 77
B
Babel fish
OP Offline
Babel fish
B
Joined: Jul 2003
Posts: 77
ya for now... hopefully though khaled will add it in a future release seeing as how it would be an incrediably simple addition to edit controls and would provide a slight performance increase i would think over the example you provided since it would b ebuilt into windows and not a scripted reg ex thing.

However that does work for now...


hmmm signed by me
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
I use this, so that the cursor position isn't reset. This makes it behave almost the same as a true numbers-only box, giving the effect that non-numeric keypresses are just halted. It also works if you paste text, triggering successive events smile
Code:
on *:dialog:<name>:edit:<id>: num-edit $dname $did
alias num-edit {
  var %a = $did($1,$2), %s = $did($1,$2,1).selstart
  if $mid(%a,%s,1) !isnum { did -ra $1-2 $remove(%a,$v1) | did -c $1-2 1 %s }
}


Oh and of course, I too would like this built-in.

Last edited by qwerty; 27/06/05 10:25 AM.

Link Copied to Clipboard