[SOLVED] wxTextCtrl - is it possible to insert gaps in order to see text tokens?
-
- Earned a small fee
- Posts: 13
- Joined: Thu Sep 21, 2017 11:59 am
[SOLVED] wxTextCtrl - is it possible to insert gaps in order to see text tokens?
Hi All,
What I am trying to achieve with my wxTextCtrl is to insert (automatically if possible) a gap/space every 5 characters and at the same time by having the 5 characters tokens being masked by the wxTE_PASSWORD style.
I've tried to add the wxTE_PASSWORD style during the control construction but it only let the text being masked.
I did implement the character filtering by hand but I could not obtain a space separator being not masked by the wxTE_PASSWORD style flag.
What I am trying to obtain is something like the image attached.
Thank you in advance.
What I am trying to achieve with my wxTextCtrl is to insert (automatically if possible) a gap/space every 5 characters and at the same time by having the 5 characters tokens being masked by the wxTE_PASSWORD style.
I've tried to add the wxTE_PASSWORD style during the control construction but it only let the text being masked.
I did implement the character filtering by hand but I could not obtain a space separator being not masked by the wxTE_PASSWORD style flag.
What I am trying to obtain is something like the image attached.
Thank you in advance.
Last edited by Astro2000 on Thu Sep 28, 2017 8:46 pm, edited 1 time in total.
-
- Earned a small fee
- Posts: 13
- Joined: Thu Sep 21, 2017 11:59 am
Re: wxTextCtrl - is it possible to insert gaps in order to see text tokens?
Forgot the image:
You do not have the required permissions to view the files attached to this post.
-
- Part Of The Furniture
- Posts: 7481
- Joined: Sat Apr 16, 2005 7:22 am
- Location: USA, Ukraine
Re: wxTextCtrl - is it possible to insert gaps in order to see text tokens?
Hi,
There is no image attached, sorry.
Moreover, wxTE_PASSWORD style is applied to the whole control. You will not be able to apply it to part of the text.
Please attach the screenshot, so that we know what you are trying to accomplish.
Also:
1. What version of the library do you use?
2. What OS?/version?
3. What toolkit (if applicable)?
Thank you.
There is no image attached, sorry.
Moreover, wxTE_PASSWORD style is applied to the whole control. You will not be able to apply it to part of the text.
Please attach the screenshot, so that we know what you are trying to accomplish.
Also:
1. What version of the library do you use?
2. What OS?/version?
3. What toolkit (if applicable)?
Thank you.
-
- Earned a small fee
- Posts: 13
- Joined: Thu Sep 21, 2017 11:59 am
Re: wxTextCtrl - is it possible to insert gaps in order to see text tokens?
lib version is 3.0.3
os: windows 10
You do not have the required permissions to view the files attached to this post.
-
- Earned a small fee
- Posts: 13
- Joined: Thu Sep 21, 2017 11:59 am
Re: wxTextCtrl - is it possible to insert gaps in order to see text tokens?
lib version: 3.0.3
os: win32
Thanks
os: win32
Thanks
-
- Part Of The Furniture
- Posts: 7481
- Joined: Sat Apr 16, 2005 7:22 am
- Location: USA, Ukraine
Re: wxTextCtrl - is it possible to insert gaps in order to see text tokens?
OK.
So let me re-phrase:
User will type "abcdefghijklmnop" and hit Enter (or Tab).
Your program will get this text and convert it to be "abcde fghij klmno p".
Did I understood correctly?
If I did - you probably need to catch EVT_FOCUS_LOST event, grab the content of the control, parse it inserting spaces as appropriate and set the value back.
If you want the "*" to appear while the user types the text you catch EVT_TEXT event and convert the current symbol typed replacing it to be "*".
Thank you.
So let me re-phrase:
User will type "abcdefghijklmnop" and hit Enter (or Tab).
Your program will get this text and convert it to be "abcde fghij klmno p".
Did I understood correctly?
If I did - you probably need to catch EVT_FOCUS_LOST event, grab the content of the control, parse it inserting spaces as appropriate and set the value back.
If you want the "*" to appear while the user types the text you catch EVT_TEXT event and convert the current symbol typed replacing it to be "*".
Thank you.
-
- Earned a small fee
- Posts: 13
- Joined: Thu Sep 21, 2017 11:59 am
Re: wxTextCtrl - is it possible to insert gaps in order to see text tokens?
Yep this is the case btw I understand that I can change the symbol displayed without altering the real character stored in the model.
Could you please give me some snippet to do that? Thanks.
Could you please give me some snippet to do that? Thanks.
-
- Moderator
- Posts: 19163
- Joined: Fri Apr 21, 2006 8:03 pm
- Location: $FCE2
Re: wxTextCtrl - is it possible to insert gaps in order to see text tokens?
If this for something like entering a registration code or similar, i would use separate wxTextCtrls.
Use the source, Luke!
-
- Earned a small fee
- Posts: 13
- Joined: Thu Sep 21, 2017 11:59 am
Re: wxTextCtrl - is it possible to insert gaps in order to see text tokens?
Yep this is the case but I can not as I need to meet the requirements. thanks
-
- Can't get richer than this
- Posts: 867
- Joined: Sun May 13, 2012 11:42 pm
- Location: France
Re: wxTextCtrl - is it possible to insert gaps in order to see text tokens?
You can also:
- Associate a validator derived from wxTextValidator (catch the wxEVT_CHAR or KEY_DOWN event (not sure about the best one) and eventually override the Validate method) to your text control.
- Or maybe this class (wxMaskedEdit) that provide mask on edit ctrl may match your need: viewtopic.php?t=6262
- Associate a validator derived from wxTextValidator (catch the wxEVT_CHAR or KEY_DOWN event (not sure about the best one) and eventually override the Validate method) to your text control.
- Or maybe this class (wxMaskedEdit) that provide mask on edit ctrl may match your need: viewtopic.php?t=6262
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
-
- Can't get richer than this
- Posts: 828
- Joined: Mon Apr 30, 2012 11:07 pm
Re: wxTextCtrl - is it possible to insert gaps in order to see text tokens?
eranon: that wxMaskedEdit version had a lot of issues (sea https://groups.google.com/forum/#!searc ... U5AhEll2AJ)
I did a working class (see https://trac.wxwidgets.org/ticket/14535) which VZ decided to abandon (too big for his little time).
I did a working class (see https://trac.wxwidgets.org/ticket/14535) which VZ decided to abandon (too big for his little time).
-
- Can't get richer than this
- Posts: 867
- Joined: Sun May 13, 2012 11:42 pm
- Location: France
Re: wxTextCtrl - is it possible to insert gaps in order to see text tokens?
OK, I never used it, just found the existence of a wxPython flavor in a first pass (https://docs.wxpython.org/wx.lib.masked ... maskededit), then quickly checked a C++ sister was discussed somewhere...Manolo wrote:eranon: that wxMaskedEdit version had a lot of issues (sea https://groups.google.com/forum/#!searc ... U5AhEll2AJ)
Nice! So, a premade way for the OPManolo wrote:I did a working class (see https://trac.wxwidgets.org/ticket/14535) which VZ decided to abandon (too big for his little time).
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
-
- Earned a small fee
- Posts: 13
- Joined: Thu Sep 21, 2017 11:59 am
Re: wxTextCtrl - is it possible to insert gaps in order to see text tokens?
Thank you guys I have some stuff to implement today so I will try...yep...I ve read about the masked control but as you have noted it is still incomplete.
I will post my results after.
I will post my results after.
-
- Earned a small fee
- Posts: 13
- Joined: Thu Sep 21, 2017 11:59 am
Re: wxTextCtrl - is it possible to insert gaps in order to see text tokens?
I forgot...do you know which the ASCII code is for the character that is used for the wxTE_PASSWORD style?
-
- Can't get richer than this
- Posts: 867
- Joined: Sun May 13, 2012 11:42 pm
- Location: France
Re: wxTextCtrl - is it possible to insert gaps in order to see text tokens?
I would say asterisk, Astro2000: https://en.wikipedia.org/wiki/Asterisk. About wxMaskedEdit, remember there're two ones: the aborted incomplete one and the Manolo's working one (following the links in this report, you can reach it as patch and as source in Git repository: https://trac.wxwidgets.org/ticket/14535).
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]