Is it possible to rotate a slider 180 degrees?

7 ビュー (過去 30 日間)
Silvia
Silvia 2013 年 5 月 28 日
編集済み: Matt J 2022 年 1 月 26 日
Hello,
I have a vertical slider, is it possible to rotate it 180 degrees?. The problem is that when I move the slider from top to down the value decreases and I would need the value increases when I move the slider from top to down.
Thank you
Silvia

採用された回答

Jan
Jan 2013 年 5 月 28 日
This is easy, when you consider the different values inside the callback:
function ExampleSlider
sliderH = uicontrol('Style', 'slider', 'position', [10, 10, 20, 100], ...
'Min', 0, 'Max', 1, 'Callback', @CB);
function CB(ObjH, EventData)
value = get(ObjH, 'Value');
disp(value)
Now 1 is written to the command window, if you drag the slider to the top, and 0 for the bottom. Now change the callback to:
function CB(ObjH, EventData)
value = 1 - get(ObjH, 'Value');
disp(value)
E voila, 0 appears for the top and 1 for the bottom. There is no need to rotate the slider, but changing the logic to interpret the slider position is enough.
  1 件のコメント
Silvia
Silvia 2013 年 5 月 29 日
Thank you Jan

サインインしてコメントする。

その他の回答 (1 件)

Hanif
Hanif 2013 年 5 月 30 日
編集済み: Matt J 2022 年 1 月 26 日
function CreateSlider
fig = figure;
Slider = uicontrol(fig,'Style','Slider',...
'Max','100','Min','0','Value','0',...
'SliderStep',[1 1]/100,...
'Position',[20 100 20 50],...
'Callback', @Slider);
end
end
function @Slider(hObj,event) SliderVal = get(hObj,'Value'); NewSliderVal = 100 - SliderVal; disp('NewSliderVal); end
% The slider will still increase when you click up, however NewSliderVal will decrease, and what ever you were using your SliderVal for, just sub in NewSliderVal instead
  1 件のコメント
Silvia
Silvia 2013 年 5 月 30 日
Thank you Hanif

サインインしてコメントする。

カテゴリ

Help Center および File Exchange3-D Scene Control についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by