Hi, I'm having some issues focusing and unfocusing a textbox. I was working on a large project when I bumped into this issue, so I made a smaller one to isolate the problem.
This small project starts with a blank layout, if you press Enter or C a textbox becomes visible, focused and an instance variable is set to True. If then you press Enter the textbox becomes invisible, unfocused and the variable is set to false. Basically, pressing Enter or C should switch the textbox on and off.
It mostly works, except for a small issue that is bothering me. After making the textbox invisible I have to press C twice in order to make it visible again (it should work with a single press), with Enter it works with a single press (as it should). It is as if even after unfocusing and making the textbox invisible the C key is still not registered by the event sheet (it could be something else, but that is the impression I'm getting).
Event sheet:
Capx:
https://www.dropbox.com/s/p8lm5tmzkus9knx/TestFocus.capx?dl=0
Some other things worth mentioning...
* If I'm understanding things correctly, when you press most keys when a textbox is focused the key "goes" into the textbox and not the event sheet, so, if there are events related to key presses they get ignored. Because of this, even if according to my event sheet, when pressing C while the textbox is visible it should become invisible, It doesn't (that's ok, it actually fits the behavior I'm trying to achieve).
* If I use C to turn the textbox visible for the first time it works ok (with a single press). But if I've pressed the C key before, I'll need to press it twice.
* At some point I made another variation, instead of making the textbox visible/invisible I created it and destroyed it each time, the results were the same.
* At some point I added a text object and the action of appending an X to it as soon as the C key was pressed (no more conditions or subevents). This was to observe if the event of pressing C was being triggered or not. I noticed that when I had to press C twice, the first press was not triggering the append action at all.
What I'm expecting to happen:
1) Press C: Textbox becomes visible
2) Press Enter: Textbox becomes invisible
3) Press C: Textbox becomes visible again
What actually happens:
1) Press C: Textbox becomes visible
2) Press Enter: Textbox becomes invisible
3) Press C: Nothing happens
4) Press C: Textbox becomes visible again
Also, another minor issue. Just by using the Focus action the textbox doesn't get focus, I had to add a Wait action to make it work. Any ideas why?
Well, I guess that is all the information I can provide. I hope somebody can tell me what am I doing wrong.
Thanks