Prevent changing values in GUI
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dear firends,
I have a querry reagrding the GUI formation in MATLAB. I have made a GUI and everything is ok but the values of tab inside the listerner called as 'angle' can be changed with edit filed and slider, which has limit obj.angle = [-10,10].
During static code given below also I have made the condtion 'if (obj.angle ~= obj.angle) & obj.angle<10 & obj.angle>-10'. Hence the static code is not executed if the slider and editfield is out of range of given limit.
But the problem is if I go inside the angle.Value and write some number not in range or limit of angle then even though the static code is not excuted but the value inside angle.Value is updated and stored. I dont want this.
Hence, I request to please suggest some way by which I can prevent the value from being updated manually inside the angle.Value. And the angle.Value should have the same limit as it has when input is given through slider or edit field.
I request to please help.
Thanking all,
Kind regards
classdef classErowin < handle
properties
fig
serial_port
UI
angle
end
properties (SetObservable, AbortSet) % for listeners
angle
end
methods
function obj = class() % constructor
obj.angle = [-10,10]
edit_filed
slider
end
end
methods (Static)
function handlePropEvents(src,evnt)
obj = evnt.AffectedObject;
switch src.Name
case {'angle'}
if (obj.angle ~= obj.angle) & obj.angle<10 & obj.angle>-10
end
end
end
end
end
1 Kommentar
VBBV
am 5 Aug. 2024
@Paramjit Yadav you could try setting the default value for angle as empty inside the static function
if (obj.angle ~= obj.angle) & obj.angle<10 & obj.angle>-10
angle.Value = [] % set the value default value
end
Antworten (1)
Walter Roberson
am 5 Aug. 2024
But the problem is if I go inside the angle.Value and write some number not in range or limit of angle then even though the static code is not excuted but the value inside angle.Value is updated and stored.
You need a set function https://www.mathworks.com/help/matlab/matlab_oop/property-set-methods.html#buq4ila-1
0 Kommentare
Siehe auch
Kategorien
Mehr zu Genomics and Next Generation Sequencing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!