theom Posted July 9, 2018 Share Posted July 9, 2018 Hi I've just started out using BJS and I really like what I've seen so far. For my application I saw the Babylon gui as a real booster since I have always ended up implementing those parts myself using what ever library I was using at the time (SVG and TheeJS for example). Currently I'm implementing a registration form using the 2D gui and I needed a password input field where the entered characters are shown as bullets. Since the InputText control doesn't seem to have this functionality I added a flag to the control and replaced the text with bullets if the flag was set. This works fine, but it kind of felt too specific to passwords. Besides there are other well known use-cases where similar behavior changes might be needed, like entering only numbers, dates, email addresses etc. I then wonder how to best implement this. I see two ways: Modify the InputText class directly to support these different input 'modes' (or types). Create separate subclasses for each different input type. Which of these (or some other way I didn't think of) makes more sense for Babylon? Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 9, 2018 Share Posted July 9, 2018 For the password part #1 would work, but I don't think #2 implementing different subclasses for each different type would be very extendable. These requirements are quite common and are often implemented as "input masks" or regular expressions. Input masks have a lot of edge cases and are harder to implement (ie: making corrections or blocking input). Regular expressions are much easier and you may want some accompanying validation text. Each regular expression can be evaluated when a letter is added or removed and perhaps you want a class to manage all the validations, so you could disable a submit button. Quote Link to comment Share on other sites More sharing options...
Guest Posted July 9, 2018 Share Posted July 9, 2018 Welcome Theom! For the specific need of password I guess a simple PasswordBox (inheriting from Textbox) could make it as the code will be really simple and it will be easier to discover For the regex support, I'm with @brianzinn Quote Link to comment Share on other sites More sharing options...
theom Posted July 9, 2018 Author Share Posted July 9, 2018 Thanks Deltakosh. Glad to be here I was kind of leaning towards subclassing but I agree with @brianzinn that a regular expressions is probably the way to go for the input mask. I'll explore this a bit further and see what I can come up with. Quote Link to comment Share on other sites More sharing options...
Guest Posted July 9, 2018 Share Posted July 9, 2018 I'm for subclassing for the PasswordBox Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.