[MaxGui] Textfield for password input?
BlitzMax Forums/BlitzMax Beginners Area/[MaxGui] Textfield for password input?
| ||
Hello all, Has anyone a small example code that turns user inputs for a textfield invisible (i.e. replacing each char with an asterik "*")? I'm quite sure there was something for this on the code archives. But I can't find it anymore. :( Grisu |
| ||
Hi Grisu, use 'TEXTFIELD_PASSWORD'-style in CreateTextField(). -Henri |
| ||
Thanks, worked! :) |
| ||
Sorry to come back to this: But is there a way to unflag (i.e. remove the passwort flag) from the textfield afterwards? I want to give the user an option to show / hide the password input as he prefers. SetGadgetText doesn't come with a flag parameter. I tried to remove and recreate the textfield (bad coding), but it still shows the "****"? | Edit | Got a workaround, you have to... 1. Hide the current Textfield. 2. Create a new Textfield and set the Password again. 3. Show the new Textfield. RedrawGadget() has no effect! Case EVENT_GADGETACTION'BUTTON_ACTION HideGadget(Proxy_PasswordTextField:TGadget) If ButtonState(Proxy_ShowPassword) = 0 Then 'Default = Hidden PW Proxy_PasswordTextField:TGadget = CreateTextField(3, 25+PNL_HEIGHT+2,MAINWINDOW_W-3-SLIDER_WIDTH-46-16, PNL_HEIGHT, ProxyPanel, TEXTFIELD_PASSWORD) 'Print "HIDDEN" Else ' Show PW Proxy_PasswordTextField:TGadget = CreateTextField(3, 25+PNL_HEIGHT+2,MAINWINDOW_W-3-SLIDER_WIDTH-46-16, PNL_HEIGHT, ProxyPanel) 'Print "VISIBLE" EndIf SetGadgetText (Proxy_PasswordTextField, ini_Proxypassword) ShowGadget(Proxy_PasswordTextField:TGadget) There has to be an easier way. |
| ||
Hi just create 2 different textfield txt_hidden and txt_showed. Then just show/hide one of them as required. |
| ||
Yeah, at least I can get around recreating the textfield every time. Thanks! I hoped to use just one though. Just changing the flag of the textfield itself somehow. |
| ||
Hi, use this function to change the mask in textfield (or remove it): Function SetPasswordMask(textField:TGadget, mask:String="") 'If mask is empty then mask is removed If Not textField Then Return Local char:Int If mask Then char = Asc(mask) SendMessageW(QueryGadget(textField, QUERY_HWND), EM_SETPASSWORDCHAR, char, 0 ) RedrawGadget(textField) EndFunction -Henri |
| ||
Perfect. Best solution. :) Thanks! Btw: BMX uses the "●" as default char. |
| ||
@Henry Nice solution, but I suppose it's Windows only... |