Forum Discussion

ChristyOtis's avatar
ChristyOtis
Community Member
3 years ago

Preventing specific keystrokes

I have several exercises where the user will enter numbers into text entry fields.  We would like to prevent them from entering dollar signs, parentheses and periods/decimal points. 

I have created layers that will pop up a character with a caption saying not to enter either the dollar sign, parentheses, or period/decimal point and a button to click to try again.  When the try again button is clicked the text entry field is cleared and the layer is hidden. 

This works perfectly when a dollar sign or parenthesis is entered.  But when a decimal point/period is entered, the layer will appear but the contents of the text entry field does not clear once the button is clicked. 

I'm attaching a sample of what I am working on.  I've been working on this for quite some time today so maybe there is something staring me in the face but I'm not seeing it.  Any and all help with figuring this out would be greatly appreciated.

Thanks!

Christy

  • I can tell you why it is doing what it is doing.

    If you will enter a decimal point on line 5, it will be cleared. If you enter $ or ( on lines 2 - 7, they will not. The reason is that when one of those keys is pressed there is a list of 7 triggers, and all of them are executed, no matter where the cursor was when the key is pressed. That means that all the layers are shown, but as fast as the processor can run through the list of triggers. It's way too fast for the monitor to respond, much less for us to be able to see them. In the end, you see the last layer in the list. Since all the layers are identical, you can't tell which one you are seeing.

    Put some sort of identifying mark on one of the error layers, and you can see it happening. For $ and (, Line number 1 is at the bottom, which is why testing line 1 gives the appearance of success, and the others don't. For the decimal, there are two lists, one for the period, and one for the number pad decimal. One list has 5 at the bottom, and the other 6. So those two lines show the correct layer for their respective entries.

    The bad news is that I have no idea how to make it work. My first impulse would be to set up a condition on each trigger to show that layer only if it is the last location where data is entered. It would work if you could find which text entry box has the focus, but I haven't been able to find that. Some one else may have an idea.

    • ChristyOtis's avatar
      ChristyOtis
      Community Member

      Thank you Walt!  You pointed me in the right direction and I was able to make it work.  The triggers I had were saying to show the error layer when pressing the period/decimal, paren or dollar sign, after clicking on the slide.  I changed all of these triggers so that the error will show after clicking on their associated text entry fields. 

  • hi,
    is there a reason to use text entry fields for the input - numeric entry fields would only allow 0 ... 9 and '.' - everything else is automatically blocked (and '.' is not a real problem for your exercise)

    Jürgen

    • ChristyOtis's avatar
      ChristyOtis
      Community Member

      Hi Jurgen,

      I wish I would have done this from the beginning, but at that time we were going to allow these keystrokes.  Since then I have over 50 exercises so going back and changing them all to have numeric entry fields instead of text would take too much time.  

      Thank you for your response!

      Christy