Hey Guys,
I want to enable the buttondownfcn for my Listbox.Due to the fact that this code works only for the RightMouseButton, i guess the LeftMouseButton has already another fcn.
The Question: Is there a way to "delete" the listbox Callback,so i can use my Callback for every MouseButton ?
function ArithmeticalMeanButton_Callback(hObject, eventdata, handles)
Data = findobj('tag','PlotedShotsListbox');
set(Data,'buttondownfcn',@ClickToChose);
function ClickToChose(gcbo,evendata,handles);
ListboxContent = get(gcbo,'String');
ListboxLine = get(gcbo,'Value');
ChosenLine = ListboxContent(ListboxLine);

 채택된 답변

Yu Jiang
Yu Jiang 2014년 8월 13일
편집: Yu Jiang 2014년 8월 13일

2 개 추천

Hi Max
In MATLAB GUI, a left mouse click triggers the execution of the listbox's Callback function and a right mouse click triggers ButtonDownFcn.
Therefore, if you would like to execute the same callback function from either the left or the right mouse button click, you may need to assign your function ClickToChose to both the 'ButtonDownFcn' and the 'calllback'.
That is to say, in the function ArithmeticalMeanButton_Callback, you may need to add the following line
set(Data,'callback',@ClickToChose);
More details of the ListBox component can be found here
A good example showing how to use ListBox can be seen via the following link
In addition, I have noiced that you use findobj to get the handle of 'PlotedShotsListBox'. Have you considered directly obtain that from handles structure? For example, you may change the line
Data = findobj('tag','PlotedShotsListbox');
to
Data = handles.PlotedShotsListbox;
This might be able to improve the efficiency of your code.
-Yu

댓글 수: 3

Max Müller
Max Müller 2014년 8월 14일
i dont know what to say.....this is a perfect answer. Thanks so much. I will read the links to improve my matlab skills.
I hope I dont annoy u if I ask for one more favor. I need to learn more about matlab handles.....do u know any side where I can find a good comparison ?
Yu Jiang
Yu Jiang 2014년 8월 14일
편집: Yu Jiang 2014년 8월 14일
You are welcome and please free feel to post more questions, if any.
You can find the detailed documentation regarding MATLAB handle classes via the following link
I would suggest you go through the examples on that webpage.
Since the handle class is part of the Object-Oriented Design in MATLAB, you may want to read the introduction to it at the following address
You can also find a good tutorial video there.
-Yu Jiang
Max Müller
Max Müller 2014년 8월 14일
Boom...that stuff is gold worth...thank...

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 App Building에 대해 자세히 알아보기

질문:

2014년 8월 13일

댓글:

2014년 8월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by