matlab gui sider with edit text
2 views (last 30 days)
Show older comments
i created a gui with slider and edit text so the i can see the changes simulatneously...i am able to see the updated value in the edit text by changing the position of the slider but i need that updated value in workspace or as ouput of variable with clicking on edit box (without running call back function)and viceverse. finally i need sigle output of both functions so that i can assign this value as input of other function. i need one output so that i can use setappdata function to transfer data between the function
function varargout = slidelast(varargin)
% SLIDELAST MATLAB code for slidelast.fig
% SLIDELAST, by itself, creates a new SLIDELAST or raises the existing
% singleton*.
%
% H = SLIDELAST returns the handle to a new SLIDELAST or the handle to
% the existing singleton*.
%
% SLIDELAST('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SLIDELAST.M with the given input arguments.
%
% SLIDELAST('Property','Value',...) creates a new SLIDELAST or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before slidelast_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to slidelast_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help slidelast
% Last Modified by GUIDE v2.5 03-Nov-2015 22:48:37
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @slidelast_OpeningFcn, ...
'gui_OutputFcn', @slidelast_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before slidelast is made visible.
function slidelast_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to slidelast (see VARARGIN)
% Choose default command line output for slidelast
handles.output = hObject;
handles.sliderListener = addlistener(handles.slider1,'ContinuousValueChange', ...
@(hObject, event) slider1_Callback(...
hObject, eventdata, handles));
%set(handles.edit1, 'String', num2str(get(handles.slider1,'value')));
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes slidelast wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = slidelast_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function edit1_Callback(hObject, eventdata, handles)
e
set(handles.slider1, 'Value', str2num(get(handles.edit1, 'String')))
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
set(handles.edit1, 'String', get(hObject,'Value'));
% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
2 Comments
Jan
on 4 Nov 2015
I do not understand this: "i need that updated value in workspace or as ouput of variable with clicking on edit box (without running call back function)and viceverse"
In which workspace do you need the updated value? Variables do not have an output. What does "with clicking on edit box" mean and why do you assume that any GUI interaction could happen without a callback function? And what exactly is meant by "viceversa" here?
Answers (1)
Walter Roberson
on 5 Nov 2015
You would not usually use setappdata() to transfer data. It is a option, but it is not used much for that purpose, not unless you start getting into large variables. See
See Also
Categories
Find more on Dialog Boxes in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!