Remove Focus from a Control?

Get help using Construct 2

Post » Thu Apr 05, 2012 10:30 pm

Right now I have a textbox and a button on a UI layer in a simple test project. I also have a keyboard event for right arrow released.

The problem is once I click on the button or inside the textbox it now has focus and the keyboard input is sent to it instead of the rest of the game stopping my keyboard event from ever happening.

So my question is how can I remove the focus from a control like that? Can I at all or is this a bug/missing option?
B
13
S
5
G
2
Posts: 306
Reputation: 3,262

Post » Fri Apr 06, 2012 2:43 am

Possible to replace the button with a sprite? This wouldn't remove the focus from the game and it can look and with a few events behave like a button..
B
14
S
6
G
5
Posts: 173
Reputation: 4,742

Post » Fri Apr 06, 2012 4:21 am

thatd work for a button but what about editing and interacting with the text in a textbox?
B
13
S
5
G
2
Posts: 306
Reputation: 3,262

Post » Sun Jun 03, 2012 2:21 pm

Hi @aridale. I was trying to figure this out for a couple of days as well. It was a pain because I was working with the ipad, and the keyboard wouldn't go away after hitting enter.

There's another thread which uses the CallJS plugin to lose focus:
http://www.scirra.com/forum/making-a-textbox-lose-focus_topic51798.html

It didn't work for me unfortunately, but I found a cheap-ish workaround.

Once I filled my textbox, and pressed enter, I captured the data in a variable and destroyed the textbox, which immediately removed focus.

Next in the same condition, I recreated the textbox in the same position, and repopulated it with the text.


B
34
S
8
G
3
Posts: 328
Reputation: 7,692

Post » Fri May 03, 2013 4:18 pm

[QUOTE=EyeHawk]

It didn't work for me unfortunately, but I found a cheap-ish workaround.

Once I filled my textbox, and pressed enter, I captured the data in a variable and destroyed the textbox, which immediately removed focus.

Next in the same condition, I recreated the textbox in the same position, and repopulated it with the text.


[/QUOTE]

Very clever indeed, I will try that tonight, did you capture the return using the Keyboard/onkeypressed event?

Thank You
TC
B
20
S
2
Posts: 22
Reputation: 1,889


Return to How do I....?

Who is online

Users browsing this forum: Kagubro, Yahoo [Bot] and 32 guests