what's the difference between handles and hObject?

조회 수: 2 (최근 30일)
John Bitzios
John Bitzios 2014년 10월 2일
댓글: Sean de Wolski 2014년 10월 3일
Where do I use handles and hObject?? And why are there function which contain sometimes both of them plus eventdata and other one of those 3 is missed?? for example function pushbutton1_Callback(hObject, eventdata, handles)

채택된 답변

Sean de Wolski
Sean de Wolski 2014년 10월 2일
hObject is the handle to the calling object; i.e. the object that is calling the function. handles is a structure with all of the handles to all objects.
The only time I use hObject is if I have two objects sharing a callback, e.g. pushbutton1 and pushbutton2 both call foo_Callback. In this scenario, I would use hObject to determine which one called or if we needed to modify the calling object.
  댓글 수: 2
John Bitzios
John Bitzios 2014년 10월 3일
편집: John Bitzios 2014년 10월 3일
If you put all of them for example function mygui(hObject,handles,eventdata) and you might use only the hObject without any handles or eventdata, is there gonna be a problem??
Sean de Wolski
Sean de Wolski 2014년 10월 3일
No, it's just an extra variable. If you don't need them, you can deny them with a tilde
mygui(hObject,~,~)

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

추가 답변 (1개)

Iain
Iain 2014년 10월 2일
handles is a structure holding ALL of the handles for the GUI.
hObject, is JUST the handle for the GUI object used.
eventdata contains specific event data - like what cell got selected on a table/what key got pressed.
  댓글 수: 1
John Bitzios
John Bitzios 2014년 10월 3일
If you put all of them for example function mygui(hObject,handles,eventdata) and you might use only the hObject without any handles or eventdata, is there gonna be a problem??

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

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by