Clear Filters
Clear Filters

I want to get currentlytyped character from editfiled becuase I want to change every current character into password character (*). Kindly help me Thanks

3 views (last 30 days)
I am using this code but I cannot get current characters.
function [] = edit2_keypressfcn(varargin)
password = get(edit2,'userdata');
key = get(fig,'currentkey');
switch key
case 'backspace'
password = password(1:end-1);
SizePass = size(password);
if SizePass(2) > 0
asterisk(1,1:SizePass(2)) = '•';
set(edit2,'String',asterisk)
else
set(edit2,'String','')
end
set(edit2,'Userdata',password)
case 'escape'
case 'insert'
case 'delete'
case 'home'
case 'pageup'
case 'pagedown'
case 'end'
case 'rightarrow'
case 'downarrow'
case 'leftarrow'
case 'uparrow'
case 'shift'
case 'return'
pus1_callback(varargin);
case 'alt'
case 'control'
case 'windows'
otherwise
password = [password get(fig,'currentcharacter')];
SizePass = size(password);
if SizePass(2) > 0
asterisk(1:SizePass(2)) = '*';
set(edit2,'string',asterisk)
else
set(edit2,'String','');
end
set(edit2,'Userdata',password) ;
end
end
  2 Comments
Rik
Rik on 12 Nov 2018
I don't believe this is possible. What you can do is making a text field that looks like an edit field, and then use this code.
BTW, this code will probably break if the users presses backspace more than there are chars in the current stored password.
Ahmer Shahid
Ahmer Shahid on 13 Nov 2018
Yes there are many problems in this that I cannot handle. Is there any other solution or some builtin functions for hiding my password. Kindly share if possible thanks.

Sign in to comment.

Accepted Answer

Jan
Jan on 13 Nov 2018
You find many many many solutions for password dialogs in the FileExchange. Simply search for the keyword "password":

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!