Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function pass = textValue
% Create figure and components.
ScreenSize = get(0,'ScreenSize');
fig = uifigure('Position',[(ScreenSize(3:4)-[300 75])/2 300 75]);
fig.CloseRequestFcn = @(fig,event)my_closereq(fig);
lbl = uilabel(fig, ...
'Position',[10 10 150 20]);
txt = uieditfield(fig,...
'Position',[10 40 150 20], ...
'Tag', 'my_textfield', ...
'ValueChangedFcn', @textChanged, ...
'ValueChangingFcn', @textChanging, ...
'UserData', '');
uiwait(fig)
function my_closereq(fig,selection)
pass = get(txt,'UserData');
delete(fig)
end
disp(pass)
end
% Callback functions
function textChanged(txt)
% disp(txt.UserData)
end
function textChanging(txt, event)
disp(event.Value);
if isempty(txt.UserData)
txt.UserData = event.Value;
else
txt.UserData = append(txt.UserData, event.Value(end));
end
val = event.Value;
val(1:length(val)) = '*';
txt.Value = val;
end