Create non-editable UI controls in a GUI with the figure toolbar

2 visualizaciones (últimos 30 días)
Amy
Amy el 6 de Feb. de 2013
I am trying to create a GUI that contains plots of data and UI controls that control what is plotted. I would like the GUI to include the figure toolbar so that the user can modify the plot annotations and such. The problem I am having is that when the button in the toolbar to edit objects in the plot is pushed, the user can then select the uicontrols and possibly move or delete them corrupting the whole GUI. Is it possible to set the uicontrols up so that they cannot be moved or deleted, using either a mouse click callback or some sort of event listener? The code below will illustrate the problem. Execute the code, then click the toolbar button to edit the plot (white arrow). When you select the popup menu, you can then move it or even delete it. I would like the toolbar to be there so that the user can edit things like the plot title and x/y labels.
h = figure;
x = linspace(0,10,10);
y{1} = sqrt(x);
y{2} = x;
y{3} = x.^2;
plot(x,y{1})
ax = gca;
set(ax,'UserData',{x,y})
F1 = @(h)get(h,'UserData');
extractYval = @(d,I)d{2}{I};
uicontrol('style','popupmenu','String',{'sqrt(x)','x','x^2'},'Value',1,...
'Callback',@(hObject,eventdata)set(get(ax,'Children'),'ydata',extractYval(get(ax,'UserData'),get(hObject,'Value'))))
set(h,'toolbar','figure')
  2 comentarios
Sean de Wolski
Sean de Wolski el 7 de Feb. de 2013
Editada: Sean de Wolski el 7 de Feb. de 2013
Oh, so your opening plot tools and moving it inside of there?
Do you want the user to be able to edit the plot period? It migth just be easier to turn plottools off.
Amy
Amy el 7 de Feb. de 2013
I would like the user to have the ability to edit the plot, add x-y labels, zoom and rotate, and such. My workaround is to have a button that will extract the plot to a new figure window for editing once the user has the desired data plotted.

Iniciar sesión para comentar.

Respuestas (2)

Image Analyst
Image Analyst el 7 de Feb. de 2013
I'm not sure I know what you're talking about. I have GUIs on all my applications and it's not possible for the user to move the control to a different location, or to remove the control from the GUI. They can only interact with them in the manner in which they were designed. How are your users able to move or delete things like buttons, checkboxes, sliders, listboxes, axes, etc. from your GUI while it's running and "corrupt" it?

Sean de Wolski
Sean de Wolski el 6 de Feb. de 2013
Editada: Sean de Wolski el 7 de Feb. de 2013
Just set their 'enable' property to 'inactive'.
More per clarifications.
Your event listener idea and current workaround are certainly good. There are a few more possibilities I can think of.
  • One is to modify the toolbar so that you wrap around plottools. Right now if the user clicks the plottools toggle button, the default behavior occurs. What you could do is have toggle on button store information about what you care about and then make it invisible etc and then call plottools. The toggle off button would restore it etc.
  • The other option is to use a 'PreSet' addlistener to listen to changes in the WindowButton_xfcns.
When plottools is enabled they become something like this:
get(gcf,'WindowButtonUpFcn')
ans =
@localModeWindowButtonUpFcn
[1x1 uitools.uimode]
{2x1 cell }
So you could detect when this change is going to occur and uicontrols, etc.
  3 comentarios
Sean de Wolski
Sean de Wolski el 7 de Feb. de 2013
I guess I ask the same question as IA then. What do you want? Shwo a picture and code example. Typically the user can't move things unless you give them a really generous callback.

Iniciar sesión para comentar.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by