Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Editor Filter  (Read 3532 times)

0 Members and 1 Guest are viewing this topic.

VEn0m

  • 85 lvl elf
  • Lurker
  • *
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 30
  • Live & Learn, Блеать!
    • View Profile
Editor Filter
« on: May 19, 2012, 02:50:05 PM »

Is there any way to make editor filter?

e.g. "Player's name" must contain only letters A-z, but now player can imput any sign including #$@ etc.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Editor Filter
« Reply #1 on: May 20, 2012, 07:33:41 AM »

You can try catching the change to editor text and change the text programatically.
For example, if the editor is called "textBox", in your window script add something like:

Code: WME Script
  1. on "textBox"
  2. {
  3.   var textBox = this.GetControl("textBox");
  4.   var someText = new String(textBox.Text);
  5.  
  6.   // ...do some processing of the text and assign it back to the editor
  7.  
  8.   textBox.Text = someText;
  9.  
  10. }
  11.  
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

VEn0m

  • 85 lvl elf
  • Lurker
  • *
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 30
  • Live & Learn, Блеать!
    • View Profile
Re: Editor Filter
« Reply #2 on: May 23, 2012, 11:06:31 AM »

Thanx a lot. That helps :)
Logged

hex

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 10
    • View Profile
Re: Editor Filter
« Reply #3 on: June 02, 2012, 11:42:51 AM »

Hello Venom, were you able to filter character input? If so, how? I don't want the player to submit only a blank "space" without letters.
Logged

VEn0m

  • 85 lvl elf
  • Lurker
  • *
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 30
  • Live & Learn, Блеать!
    • View Profile
Re: Editor Filter
« Reply #4 on: June 30, 2012, 09:43:16 PM »

Hello Venom, were you able to filter character input? If so, how? I don't want the player to submit only a blank "space" without letters.

this is the "draft" of the filter

Code: [Select]
  var NewEditorText =new String(Editor.Text);
 
  if ((key >= 65 && key <=90) || (key >= 97 && key <= 122)) // A-Z or a-z
  {
  Editor.Text = NewEditorText;
  }
  else
  {
if (key!=8) //backspace
{
var lenght = NewEditorText.Length;
var ClearText = NewEditorText.Substr(0,lenght-1); //remove last digit
Editor.Text = ClearText;
}
  }
 
« Last Edit: July 13, 2012, 11:50:22 AM by VEn0m »
Logged

hex

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 10
    • View Profile
Re: Editor Filter
« Reply #5 on: July 01, 2012, 06:30:51 AM »

Ah, I see what Mnemonic meant by catching the change to the editor. Didn't realize that was possible. Very helpful, thanks :)

For anyone needing this filter, append an equal sign to the operators to capture the letters Aa and Zz: <=, >=
Logged

VEn0m

  • 85 lvl elf
  • Lurker
  • *
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 30
  • Live & Learn, Блеать!
    • View Profile
Re: Editor Filter
« Reply #6 on: July 01, 2012, 06:41:40 AM »

Ah, I see what Mnemonic meant by catching the change to the editor. Didn't realize that was possible. Very helpful, thanks :)

For anyone needing this filter, append an equal sign to the operators to capture the letters Aa and Zz: <=, >=


ooops, my bad :) Thnx for fixing!
Logged
 

Page created in 0.032 seconds with 25 queries.