Why is uistyle("Icon",'error') making a transparent icon when the UITable is not on the first tab of a tabgroup?

7 ビュー (過去 30 日間)
Breif description of what I am working on:
I am attempting to build a custom component in MATLAB appdesigner (R2023b) that functions as status bar/message center that I can use in any applications I build going forward. The plan was the have a tab group with three tabs: the first would have all messages (including 'warnings' and 'errors'), the second would contain only those designated as 'warnings', and the third would contain only those designated as 'errors.' I wanted each tab to contain a table where each row is a single message with a message ID. I would then use the 'Icon' feature in the 'uistyle' function to display 'warning' and 'error' icons in the appropriate message cells.
The issue:
The 'error' icon on any UITable not on the first tab of a tab group always appears to be transparent. I've built up the simplest possible custom component that recreates the issue and included the code at the bottom of this post. In it, you can see that I use a for-loop to set the exact same uistyle on each table. The only difference is the tab that table exists on. For any tab that isn't the first one, the error icon color gets messed up. This doesn't appear to happen for any other icon types. Screenshots of my example code exhibitng the behavior are included below. This seems pretty clearly like unintended behavior, but I'm hoping for a way to work around it anyways.
classdef Example < matlab.ui.componentcontainer.ComponentContainer
% Properties that correspond to underlying components
properties (Access = private, Transient, NonCopyable)
TabGroup matlab.ui.container.TabGroup
Tab1 matlab.ui.container.Tab
UITable_1 matlab.ui.control.Table
Tab_2 matlab.ui.container.Tab
UITable_2 matlab.ui.control.Table
Tab3 matlab.ui.container.Tab
UITable_3 matlab.ui.control.Table
Tab4 matlab.ui.container.Tab
UITable_4 matlab.ui.control.Table
end
properties (Access = private)
first_time_run_flag logical = true;
end
methods (Access = protected)
% Code that executes when the value of a public property is changed
function update(comp)
% I use a flag to prevent the code from running this code more
% than a single time for the purposes of this example code
if comp.first_time_run_flag
dataToPutInTables = {1,'test info';2,'test question';3,'test warning';4,'test error';5,'test success'};
%Iterate through each table and add the data and format the
%styles
for i=1:4
currentTableName = sprintf('UITable_%d',i);
comp.(currentTableName).Data = dataToPutInTables;
addStyle(comp.(currentTableName),uistyle("Icon",'info'),"cell",[1,2]);
addStyle(comp.(currentTableName),uistyle("Icon",'question'),"cell",[2,2]);
addStyle(comp.(currentTableName),uistyle("Icon",'warning'),"cell",[3,2]);
addStyle(comp.(currentTableName),uistyle("Icon",'error'),"cell",[4,2]);
addStyle(comp.(currentTableName),uistyle("Icon",'success'),"cell",[5,2]);
end
comp.first_time_run_flag = false;
end
end
% Create the underlying components
function setup(comp)
comp.Position = [1 1 320 240];
comp.BackgroundColor = [0.94 0.94 0.94];
% Create TabGroup
comp.TabGroup = uitabgroup(comp);
comp.TabGroup.Position = [1 1 320 240];
% Create Tab1
comp.Tab1 = uitab(comp.TabGroup);
comp.Tab1.Title = 'Tab1';
% Create UITable_1
comp.UITable_1 = uitable(comp.Tab1);
comp.UITable_1.ColumnName = {'ID'; 'Message'};
comp.UITable_1.RowName = {};
comp.UITable_1.Position = [1 1 318 215];
% Create Tab_2
comp.Tab_2 = uitab(comp.TabGroup);
comp.Tab_2.Title = 'Tab2';
% Create UITable_2
comp.UITable_2 = uitable(comp.Tab_2);
comp.UITable_2.ColumnName = {'ID'; 'Message'};
comp.UITable_2.RowName = {};
comp.UITable_2.Position = [1 1 318 215];
% Create Tab3
comp.Tab3 = uitab(comp.TabGroup);
comp.Tab3.Title = 'Tab3';
% Create UITable_3
comp.UITable_3 = uitable(comp.Tab3);
comp.UITable_3.ColumnName = {'ID'; 'Message'};
comp.UITable_3.RowName = {};
comp.UITable_3.Position = [1 1 318 215];
% Create Tab4
comp.Tab4 = uitab(comp.TabGroup);
comp.Tab4.Title = 'Tab4';
% Create UITable_4
comp.UITable_4 = uitable(comp.Tab4);
comp.UITable_4.ColumnName = {'ID'; 'Message'};
comp.UITable_4.RowName = {};
comp.UITable_4.Position = [1 1 318 215];
end
end
end
Class name and filename must match.
  1 件のコメント
Aaron Coville
Aaron Coville 2024 年 5 月 10 日
A friend of mine has since tested this is 2022b and found that the issue does not exist in that release. Here's a screenshot of his:

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

採用された回答

Kevin Holly
Kevin Holly 2024 年 5 月 10 日
編集済み: Adam Danz 2024 年 10 月 4 日
Update: This issue is fixed in MATLAB R2024b.
That is interesting.
Here is a workaround for now, you can just hardcode the path to the file as such:
addStyle(Tablelist(ii),uistyle("Icon",'C:\Program Files\MATLAB\R2024a\ui\icons\24x24\error.svg'),"cell",[4,2]);
above is the path for mine. Yours will be in the R2023b folder.
  1 件のコメント
Aaron Coville
Aaron Coville 2024 年 5 月 10 日
Thank you! I was wondering if creating my own png would be a viable workaround, but linking directly to the original file is much preferred! I can't imagine that the icon I would have produced would look very good by comparison...

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by