Текстовое поле в формате +7 (999) 999-99-99

Здравствуйте. Подскажите как для TextBox задать маску ввода. Нужно чтобы в поле можно было вводить только цифры в формате телефона. Я хочу сделать маску для этого текстового поля в формате +7 (999) 999-99-99.

Screenshot_3

Как это сделать? Или есть расширение позволяющее так сделать?

Нашла расширение TextBoxPlus, но не понимаю как с его помощью сделать маску ввода.

You should not need an extension for this, if you use the textbox changed event to track how many digits have been entered so far and force them into your mask.

I unfortunately can't code for a few hours.

Edit - I coded this in blocks, but it came out slow (multi-second per key stroke) and contradictory to how I thought the text changed event should work.

I take back my recommendation to try this in blocks, and throw it up to the extension developers.

I continued to experiment with the When Text Changed Textbox event, and found it is only usable for when you don't plan to change its text contents.

Here's a workaround based on spreading out the input mask across a Horizontal Arrangement filled with alternating inactive and active mask parts:

Ignore Textbox1. I deleted it and its blocks, because of the failed text replacement attempts I used it for.

Here are the blocks to force legal input across the Arrangement, and to gather the phone number.

initialize global phoneMask to

These draggable blocks allow use of the tab character to hop to the next part of the mask, and they depend on the numeric input text boxes having their Hints initialized with masks (9,99,999,...) to guide the user and to support changing the background color of mask parts with the wrong length.

phone_number_mask.aia (4.3 KB)

Adjusting the widths of these mask parts was a pain in the neck. I am thinking of a way to do this with only one textbox sandwiched between two Buttons, but that is for a later post.

Благодарю. Получается очень громоздко и неудобно для пользователя. Много элементов. Сохраню в копилку идей.

С маской не получилось реализовать, сделала так:

Текстовое поле разрешает ввод только цифр. При потере фокуса, идёт проверка.

Here is a different approach, where you can use the same code for different masks.

Designer:


multi_mask_input.aia (7.0 KB)

Sample run:
Sample run

Blocks: