I have a GUI consisted of a slider, a press button and 4 axes. I have placed the WindowScrollWheelFcn and I get the following error
"Warning: Setting the "WindowScrollWheelFcn" property is not permitted while this mode is active.
> In matlab.uitools.internal.uimodemanager>localModeWarn (line 211)
In matlab.uitools.internal.uimodemanager>@(obj,evd)(localModeWarn(obj,evd,hThis)) (line 86)
In fresh>Load_image_Callback (line 320)
In gui_mainfcn (line 95)
In fresh (line 42)
In matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)fresh('Load_image_Callback',hObject,eventdata,guidata(hObject)) "
Any help?

 Respuesta aceptada

Rik
Rik el 10 de Jun. de 2018

1 voto

You have the target figure open. You probably have the selector mode on (the mouse cursor icon in the menu bar), or maybe the pan mode. You need to have the current mode turned off if you want to initialize some callback that may interfere with it.
The only time I've seen this error myself, is when I wanted to set a ButtonDownFcn while the selector mode was on.
This is an example of why it is generally a good idea to have a GUI as locked down as you can while you set all the properties. (I often even set Visisble to off when initializing to circumvent any user interaction messing up the settings)

12 comentarios

Stelios Fanourakis
Stelios Fanourakis el 10 de Jun. de 2018
I don't understand much of those things as I am a new to GUI in general. Can you please explain me what are the on and off and how can I have it locked down as you do?
Rik
Rik el 10 de Jun. de 2018
There is a menu bar in each figure with some common controls: pan, zoom, rotate, etc. One of those is activated and blocks setting of the callback. Making sure none of them is activated should solve your issue.
The code below is a pattern I frequently use. I try to set all callbacks and other properties before allowing the user to interact with my figure by setting the Visible property to off and after I have set all the properties and callback setting it back to on.
hfig=figure(1)
clf(hfig)%clear any old content, reset figure
set(hfig,'Visible','off')%hide figure to prevent user interaction
%you can also use hfig.Visible='off'; >=R2014b
set(gcf,'menu','none')
%load data, set object properties, set callbacks
set(hfig,'Visible','on')%show figure and wait for user interaction
Stelios Fanourakis
Stelios Fanourakis el 10 de Jun. de 2018
Editada: Stelios Fanourakis el 10 de Jun. de 2018
Actually the fig I created in guide do not have any menu bar or controls. It is just a plain figure with 4 axes, a button and a slider
Rik
Rik el 11 de Jun. de 2018
That's why I don't use GUIDE, it causes a lot of trouble in return for not much help.
Have you tried closing the fig, re-opening and then setting the callback?
You can get the menu bar back by setting the menu property to 'figure'. then you might see which mode is enabled.
If none of this works, please edit your question to include a zip file with all relevant files and tell us which button to push to trigger the error.
Stelios Fanourakis
Stelios Fanourakis el 11 de Jun. de 2018
How do I set menu property to 'figure'?
Rik
Rik el 12 de Jun. de 2018
If your GUI is the last figure you clicked on, gcf will give you a handle to that figure. So set(gcf,'menu','figure') should work.
Stelios Fanourakis
Stelios Fanourakis el 25 de Sept. de 2019
Rik may you help me again please? After a year I still get the same error when I try to use mouse wheel to synchronize the slider movements. How do I solve this error? Where am I supposed to put that line?
Thanks in advance
Rik
Rik el 25 de Sept. de 2019
I assume this relates to this new question, in which case the answer is that you need to disable whatever interactive mode you currently have enabled in order to set a callback.
Stelios Fanourakis
Stelios Fanourakis el 25 de Sept. de 2019
I don't know what interactive mode I currently have enabled. How can I find out?
Stelios Fanourakis
Stelios Fanourakis el 25 de Sept. de 2019
When I go with my cursor above the axes I see the rotation is enabled. When I manually deselct it then the scrolling becomes zoom in/out.
I don't want neither of those. I want to be used as it used to. Scrolling should move the sliders
I used this
As
disableDefaultInteractivity(handles.axes1);
But still the same error
Rik
Rik el 25 de Sept. de 2019
I think it makes more sense to continue this discussion in your new thread. You should also mention which release you're using.
It might also be helpful to attach an example. Make sure to restart Matlab, and describe every step you take from there to reproduce the issue.

Iniciar sesión para comentar.

Más respuestas (1)

Steven Lord
Steven Lord el 12 de Jun. de 2018

0 votos

Before you tried to set the WindowScrollWheelFcn, did you turn zoom on, pan on, or rotate3d on? See the Tips section of the documentation pages for the zoom, pan, or rotate3d functions. Each says "Do not change figure callbacks within an interactive mode." The WindowScrollWheelFcn is a figure callback.

Categorías

Más información sobre Interactive Control and Callbacks en Centro de ayuda y File Exchange.

Preguntada:

el 10 de Jun. de 2018

Comentada:

Rik
el 25 de Sept. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by