-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdlgSelec.m
101 lines (76 loc) · 2.9 KB
/
dlgSelec.m
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
%
% Crea un cuadro de diálogo genérico para seleccionar elementos de una
% lista.
%
% PARAMS:
% - ls -> Lista de elementos (cell)
% - dft -> Posición en 'ls' del elemento seleccionado por defecto
% - title -> Título de la ventana
%
function varargout = dlgSelec(varargin)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @dlgSelec_OpeningFcn, ...
'gui_OutputFcn', @dlgSelec_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
function dlgSelec_OpeningFcn(hObject, eventdata, handles, varargin)
ptrLgSetUIStrings(hObject);
handles.output.ok = false;
handles.output.selection = [];
handles.valueList = varargin{1};
dft = varargin{2};
title = varargin{3};
set (handles.dlg ,'Name', title);
set (handles.ls, 'String', handles.valueList);
set (handles.ls, 'Value', dft);
ptrCenterWindow(hObject);
% Update handles structure
guidata(hObject, handles);
% Make the GUI modal
set(handles.dlg,'WindowStyle','modal')
% UIWAIT makes dlgEntrenar wait for user response (see UIRESUME)
uiwait(handles.dlg);
function varargout = dlgSelec_OutputFcn(hObject, eventdata, handles)
% Get default command line output from handles structure
varargout = struct2cell(handles.output);
% The figure can be deleted now
delete(handles.dlg);
function dlg_CloseRequestFcn(hObject, eventdata, handles)
btnCancelar_Callback(hObject, eventdata, handles);
function dlg_KeyPressFcn(hObject, eventdata, handles)
% Check for "enter" or "escape"
if isequal(get(hObject,'CurrentKey'),'escape')
btnCancelar_Callback(hObject, eventdata, handles);
end
if isequal(get(hObject,'CurrentKey'),'return')
btnAceptar_Callback(hObject, eventdata, handles);
end
function ls_Callback(hObject, eventdata, handles)
action = get (handles.dlg, 'SelectionType');
if strcmp(action,'open'),
btnAceptar_Callback(hObject, eventdata, handles)
end
function btnAceptar_Callback(hObject, eventdata, handles)
if isempty(handles.valueList), return, end
v_sel = get(handles.ls, 'Value');
handles.output.selection = v_sel;
handles.output.ok = true;
guidata(hObject, handles);
uiresume(handles.dlg);
function btnCancelar_Callback(hObject, eventdata, handles)
handles.output.ok = false;
handles.output.selection = '';
guidata(hObject, handles);
uiresume(handles.dlg);