Filter löschen
Filter löschen

Way to make timescope "alwaysontop" or embed timescope object in uifigure?

6 Ansichten (letzte 30 Tage)
Aaron Borgman
Aaron Borgman am 16 Mär. 2022
Beantwortet: Namnendra am 27 Apr. 2023
I'm using timescope inside an App Designer app, and I'm trying to figure out a way to keep the timescope window always on top of everything.
Unlike uifigure - there appears to be no "alwaysontop" WindowStyle for the timescope.
Is there a way to force timescope alwaysontop, or a way to embed a timescope object into a uifigure to make that possible?

Antworten (1)

Namnendra
Namnendra am 27 Apr. 2023
Hey Aaron,
The timescope object in MATLAB does not have an option to set it as always on top, but you can achieve this behavior by embedding the timescope object in a uifigure object and setting the WindowStyle property of the uifigure object to 'modal'. The 'modal' WindowStyle will make the uifigure object always on top of all other windows and dialogs.
Here is an example code snippet that demonstrates how to embed a timescope object in a uifigure object:
% Create a uifigure object
fig = uifigure('WindowStyle', 'modal');
% Create a timescope object and set its Parent property to the uifigure object
ts = timescope('Parent', fig);
% Set the layout of the uifigure object to 'fit'
fig.Layout.Row = 1;
fig.Layout.Column = 1;
fig.Layout.RowSpan = 2;
% Add some controls to the uifigure object
uicontrol('Parent', fig, 'Style', 'slider', 'Position', [20 20 200 20]);
% Display the uifigure object
fig.Visible = 'on';
In this example, the timescope object is embedded in a uifigure object with a 'modal' WindowStyle. The layout of the uifigure object is set to 'fit' to fill the entire window. You can add any other controls or UI elements to the uifigure object as needed.
By default, the uifigure object will be displayed with a title bar and close button. If you want to remove these, you can set the 'MenuBar' and 'CloseRequestFcn' properties of the uifigure object as follows:
fig.MenuBar = 'none';
fig.CloseRequestFcn = @(~,~)disp('Close button disabled');
This will remove the title bar and close button from the uifigure object, preventing the user from closing it. You can add your own custom close function to the CloseRequestFcn property to handle the close event as needed.

Kategorien

Mehr zu Develop uifigure-Based Apps finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by