Skip to content

Commit 76b6daa

Browse files
committed
fixes #79 PasswordField Value property isn't updated in R2024a web app
1 parent 41a08d0 commit 76b6daa

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info>
3+
<Category UUID="FileClassCategory">
4+
<Label UUID="design"/>
5+
</Category>
6+
</Info>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info location="PasswordFieldTest.mlapp" type="File"/>

widgets/+wt/PasswordField.m

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,28 +101,39 @@ function onPasswordChanged(obj,evt)
101101
% Grab the data in string format
102102
newValue = string(evt.Data);
103103
oldValue = obj.Value;
104+
previousData = evt.PreviousData;
104105

105106
% Look at the states
106-
if endsWith(evt.PreviousData, newline)
107-
% This is needed to ignore double events
108-
109-
% Clear the newline from the uihtml data
110-
newValue = erase(newValue, newline);
111-
obj.PasswordControl.Data = newValue;
112-
113-
elseif endsWith(newValue, newline)
107+
if endsWith(newValue, newline)
114108
% Enter key was pressed in the uihtml component
115109

116110
% Clear the newline from the new value
117111
newValue = erase(newValue, newline);
112+
113+
% Store value
114+
obj.Value = newValue;
118115

119116
% Trigger event
120117
evtOut = wt.eventdata.PropertyChangedData('Value', newValue);
121118
notify(obj,"ValueChanged",evtOut);
122119

120+
elseif endsWith(previousData, newline)
121+
% This is needed to ignore double events
122+
123+
% Clear the newline from the uihtml data
124+
newValue = erase(newValue, newline);
125+
126+
% Store value
127+
obj.Value = newValue;
128+
129+
% Trigger event
130+
evtOut = wt.eventdata.PropertyChangedData('Value', ...
131+
newValue, oldValue);
132+
notify(obj,"ValueChanging",evtOut);
133+
123134
elseif newValue ~= oldValue
124135

125-
% Store new result
136+
% Store value
126137
obj.Value = newValue;
127138

128139
% Trigger event
53.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)