Prevent changing values in GUI

조회 수: 3 (최근 30일)
Paramjit Yadav
Paramjit Yadav 2024년 8월 5일
답변: Walter Roberson 2024년 8월 5일
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
VBBV
VBBV 2024년 8월 5일
@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

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2024년 8월 5일
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.

카테고리

Help CenterFile Exchange에서 Genomics and Next Generation Sequencing에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by