フィルターのクリア

Unable to add uicontrol to uifigure

16 ビュー (過去 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.
  1 件のコメント
Marc Elpel
Marc Elpel 2021 年 3 月 5 日
Excellent - thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by