GUI slider value change when majorstep is changed from default?

1 Ansicht (letzte 30 Tage)
Gaszton
Gaszton am 14 Jan. 2013
Hello,
i experienced a very strange behaviour of GUI (made with GUIDE) sliders, If I change the major step of a vertical slider, e.g. 0.02 and the minor step is 0.01, the value of the slider changes from 0 to 0.08. The inspector in guide shows 0 for the value, but the thumbbar of the slider is not at the bottommost position. If i start the GUI, the thumbbar is still at the same position, and if i check the value of the slider, it is 0.08 instead of 0.
Test it with a blank gui, add a vertical slider:
  • max: 1.0
  • min: 0.0
  • sliderstep: [0.01,0.02]
  • x: 0.01
  • y: 0.02
  • value: 0.0
when you start the gui, the slider is value is not 0.0
  6 Kommentare
Gaszton
Gaszton am 15 Jan. 2013
I tested on a win7 and an xp machine, both r2012b, no difference.
in GUIDE, the position of the slider changes immediatly as i modify the majorsliderstep, but the value is still 0.0 in the inspector.
with default settings: http://i48.tinypic.com/111hspd.jpg
after changing sliderstep: http://i45.tinypic.com/35250rr.jpg
Jing
Jing am 16 Jan. 2013
Bearbeitet: Jing am 16 Jan. 2013
This seems to happen only when the major step is smaller than the default one and it's a vertical slider. I can't reproduce this with a horizontal slider.

Melden Sie sich an, um zu kommentieren.

Antworten (3)

Azzi Abdelmalek
Azzi Abdelmalek am 14 Jan. 2013
Bearbeitet: Azzi Abdelmalek am 14 Jan. 2013
% In your opening function insert
% slider1 is your slider's tag
set(handles.slider1,'value',0,'Min',0,'Max',1,'Sliderstep',[0.01,0.02])
  4 Kommentare
Gaszton
Gaszton am 14 Jan. 2013
Bearbeitet: Gaszton am 14 Jan. 2013
Thank you, i am not a newbie you can try to make such a slider with guide, and see how it behaves.
Azzi Abdelmalek
Azzi Abdelmalek am 14 Jan. 2013
You are right, I'am getting the same problem, which I can't explain

Melden Sie sich an, um zu kommentieren.


Azzi Abdelmalek
Azzi Abdelmalek am 14 Jan. 2013
Try this in this order
set(handles.slider1,'Min',0,'Max',1,'Sliderstep',[0.01,0.02])
set(handles.slider1,'value',0)
%or
set(handles.slider1,'Min',0,'Max',1,'Sliderstep',[0.01,0.02],'value',0)

Image Analyst
Image Analyst am 15 Jan. 2013
Bearbeitet: Image Analyst am 15 Jan. 2013
I'm not able to reproduce. I displayed the value in the movement callback and it was exactly as expected: 0.01 after the first small click, and incrementing by 0.01 or 0.02 depending on where in the slider you clicked.
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
sliderValue = get(hObject,'Value') % Spit value out to command line.
return;
The thumbbar of the slider also does not move when I change the step values. Since the value is 0 it stays slammed up against one side. I'm running R2012b 64 bit on Windows 7.
  9 Kommentare
Gaszton
Gaszton am 17 Jan. 2013
with value set to 1, it works fine, starts with value 1
Jan
Jan am 18 Jan. 2013
So would this be a work aorund?
set(handles.slider1, 'value', 1);
drawnow;
set(handles.slider1, 'value', 0);

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by