Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for deselection of HighlightedValue. Fixes in BaseApp. #71

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions widgets/+wt/+apps/BaseApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,21 @@ function forceUpdate(app)
%% Constructor / destructor
methods (Access = public)

function app = BaseApp(varargin)
function app = BaseApp(options)

% Constructor

arguments
options.?wt.apps.BaseApp
options.Preferences (1,1) wt.model.Preferences = wt.model.Preferences;
options.PreferenceGroup (1,1) string = "";
end

% Check for preference input and assign it first, in case
% Preferences was subclassed
app.Preferences = options.Preferences;
app.PreferenceGroup = options.PreferenceGroup;
options = rmfield(options, ["Preferences" "PreferenceGroup"]);

% Create the figure and hide until components are created
app.Figure = uifigure( ...
Expand Down Expand Up @@ -132,8 +145,9 @@ function forceUpdate(app)
app.setup();

% Set any P-V pairs
if ~isempty(varargin)
set(app, varargin{:});
cellArgs = namedargs2cell(options);
if ~isempty(cellArgs)
set(app, cellArgs{:});
end

% Register the app with App Designer
Expand All @@ -151,11 +165,12 @@ function forceUpdate(app)
% Update the title
app.updateTitle();

% Force drawing to finish
drawnow

% Now, make it visible
app.Figure.Visible = 'on';
if isfield(options, 'Visible')
app.Figure.Visible = options.Visible;
else
app.Figure.Visible = 'on';
end

end %function

Expand All @@ -164,7 +179,13 @@ function delete(app)
% Destructor

% Store last position in preferences
if isscalar(app.Figure) && isvalid(app.Figure)

% Note: Use isprop instead of isvalid.
% If a user deletes the figure instead of the app,
% this delete method is still triggered. Although
% not yet fully deleted (prop values still available),
% the app and figure are not valid at this point.
if isscalar(app.Figure) && isprop(app.Figure, "Position")
app.setPreference('Position',app.Figure.Position)
end

Expand Down Expand Up @@ -425,7 +446,7 @@ function updateTitle(app)

function value = get.PreferenceGroup(app)
value = app.PreferenceGroup;
if isempty(value)
if ~strlength(value)
value = class(app);
end
value = matlab.lang.makeValidName(value);
Expand Down
4 changes: 4 additions & 0 deletions widgets/+wt/ListSelector.m
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,10 @@ function shiftListBoxIndex(obj, shift)
end
end
function set.HighlightedValue(obj,value)
if isempty(value)
obj.ListBox.Value = {};
return;
end
if isempty(obj.ItemsData)
[~, obj.ListBox.Value] = ismember(value, obj.Items);
else
Expand Down
1 change: 1 addition & 0 deletions widgets/+wt/ListSelectorTwoPane.m
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ function shiftListBoxIndex(obj, shift)
end
function set.HighlightedValue(obj,value)
if isempty(value)
obj.RightList.Value = {};
return;
end
if isempty(obj.ItemsData)
Expand Down