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

1 次查看(过去 30 天)
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 个评论
Rik
Rik 2018-11-12
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 2018-11-13
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.

请先登录,再进行评论。

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by