Need help with advanced textbox

Get help using Construct 2

Post » Fri Dec 16, 2016 10:00 pm

What i need:
i need to type number in textbox object but typed number cannot be greater than 99 or not less than 0
(i use advanced textbox object)

how i should create events to block typing text (numbers) than two characters?
B
25
S
8
Posts: 219
Reputation: 2,181

Post » Fri Dec 16, 2016 10:17 pm

Here's one way. Under the on changed event check all the inputted characters and only keep the digits, then only keep the first two.

https://dl.dropboxusercontent.com/u/542 ... input.capx
B
94
S
33
G
113
Posts: 5,357
Reputation: 73,275

Post » Fri Dec 16, 2016 10:20 pm

Thats p[erfect also first time i see 'len' expression
Thanks Rojo!

R0J0hound wrote:Here's one way. Under the on changed event check all the inputted characters and only keep the digits, then only keep the first two.

https://dl.dropboxusercontent.com/u/542 ... input.capx
B
25
S
8
Posts: 219
Reputation: 2,181

Post » Sun Dec 18, 2016 5:34 pm

@R0J0hound how i can make condition,
when textboxs is finished editing do something
?
B
25
S
8
Posts: 219
Reputation: 2,181

Post » Sun Dec 18, 2016 10:11 pm

It depends on how you specify when editing is done.

If it's when nothing has been inputted for some timeframe then you can do that with a timer. You start or restart the timer when the "on text changed" trigger is run. A possible implementation could be:

Code: Select all
global number myTimer=-1

on text changed
--- set myTimer to 60

every tick
--- subtract 1 from my timer

myTimer = 0
--- do something


Another idea is to do stuff when the TextBox no longer has focus. That could be when you click and the mouse is no longer over the TextBox or something.

There are probably other ways. The simplest would be to just have a button to do something.
B
94
S
33
G
113
Posts: 5,357
Reputation: 73,275


Return to How do I....?

Who is online

Users browsing this forum: YoHoho and 13 guests