Unable to add uicontrol to uifigure

22 views (last 30 days)
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

Accepted Answer

Cris LaPierre
Cris LaPierre on 5 Mar 2021
Try using uieditfield instead of uicontrol. See here.

More Answers (0)

Categories

Find more on Maintain or Transition figure-Based Apps 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!