2 Replies Latest reply on May 14, 2006 12:23 AM by Newsgroup_User

    How do i prevent the user from entering a RETURN/ENTER key into their username?

    leewilson86 Level 1
      Hello,
      i am currently trying to make a login system where the username will obviously enter their username.

      I have made my user input box editable and set up variables to accept the user input and store them into variables, along with error prevention for blank fields.

      However i cannot prevent the user from hitting the "enter"/"return" key. When i hit "enter" the user input box box gets larger as the type curser moves onto the next line and when the username is stored in a variable it is stored as "theuser RETURN" so when variable is passed to the next frame and is recalled by another text box to display the username, the user name has a carriage return.

      I want to prevent this, anyone got any suggestions? or know of any websites i can visit which will explain this to me nicely??

      Thank you
        • 1. Re: How do i prevent the user from entering a RETURN/ENTER key into their username?
          Level 7
          suggestion:
          don't make the edit field editable right from the start.
          rather attach a behaviour to the field/text-sprite like:

          property mySprite, myMember

          on beginsprite me
          Sprite = me.spritenum
          -- this is the channel-number of the editbox
          myMember = mySprite.member.number
          -- this is the field/text-member
          member(myMember).editable = FALSE
          end beginsprite

          on mouseup me
          -- when i get clicked for editing, then set me editable
          member(mymember).editable = TRUE
          the keydownscript = "MyKeyhandler"
          -- this sets the keyhandler to YOUR keyhandler, see below
          end mouseup


          You would then need to have YOUR keyhandler in any mociesript and there you
          would block any unwished key, while editing

          on MyKeyhandler
          case the key of
          RETURN:
          stopevent;
          otherwise
          pass;
          end case
          end MyKeyhandler


          in the end you would attach a behaviour to any "Submit"-button (this is the
          one that "gets" the userinput" and performs further action according to your
          wishes and decisions)

          on mouseup
          the keydownscript = EMPTY
          -- this resets to normal
          user-ID = member("Whatever the number or name of your editfield
          is").text
          member("Whatever the number or name of your editfield is").editable
          = FALSE
          -- .....
          -- any further actions to make in your project
          -- to get along with the entered User-ID
          end mouseup


          something like this, I guess

          Peter


          • 2. Re: How do i prevent the user from entering a RETURN/ENTER key into their username?
            Level 7
            This behavior attached to an editable member should work as well.


            on keyDown
            if the key <> return and the key <> enter then pass
            end



            -- passes key to editable member only if not return or enter