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