Unable to add uicontrol to uifigure

조회 수: 18 (최근 30일)
Marc Elpel
Marc Elpel 2021년 3월 5일
댓글: Marc Elpel 2021년 3월 5일
I'm trying to build a custom form with drop down menus and edit boxes for data entry. The drop-downs are dynamic/set by user selections in the other items.
I was able to built the figure using dropdown and buttons, but when I tried adding an edit box the code failed with error "Functionality not supported with figures created with the uifigure function. For more information, see Graphics Support in App Designer."
I've tried changing from uifigure to figure, but that breaks other parts of the code.
Some specifics:
  1. Main app designed in App Designer
  2. Main App calls separate class defined as Tasks < handles (define as handles so the obj passed to callbacks worked properly)
  3. Tasks creates a separate figure which gets user input and uses uiwait to hold until done.
  4. Everything works for the drop-downs, but cannot add the edit box to get a value from a user. (online help suggests creating the edit box via uicontrol which creates the error above.)
Creation code (editted down to key parts)
classdef Tasks < handle
...
function obj = Tasks()
% Create figure for user input
obj.Figure = uifigure('Position',[100 100 400 300]);
% Create and populate the task list dropdown selections
obj.lbTasks = uidropdown(obj.Figure,'Items',obj.TaskNames, ...
'Position',[50,250,150,25],'ValueChangedFcn', @obj.figInputs_Changed);
% Create & populate the consumable object list
obj.lbObjects = uidropdown(obj.Figure, 'Items', {'Component'}, ...
'Position',[225,250,150,25],'Enable','off','ValueChangedFcn', @obj.figInputs_Changed);
% Create an edit box for entering values
obj.edValue = uicontrol(obj.Figure, 'Style', 'edit', ...
'Position',[50,200,150,25],'Enable','off','ValueChangedFcn', @obj.figInputs_Changed);
% Create the Save and Cancel buttons
obj.btnSave = uibutton(obj.Figure, 'Text', 'Save', ...
'Position',[100,50,80,25],'ButtonPushedFcn', @obj.BtnPushed_Callback);
obj.btnCancel = uibutton(obj.Figure, 'Text', 'Cancel', ...
'Position',[200,50,80,25],'ButtonPushedFcn', @obj.BtnPushed_Callback);
end

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 3월 5일
Try using uieditfield instead of uicontrol. See here.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by