이 페이지의 최신 내용은 아직 번역되지 않았습니다. 최신 내용은 영문으로 볼 수 있습니다.
이벤트는 객체와 관련하여 일부 변경이나 동작이 발생할 경우 브로드캐스트되는 알림입니다. 리스너는 특정 이벤트가 발생할 때 실행되는 함수를 정의합니다. 클래스는 이벤트를 정의하고 트리거할 수 있습니다. MATLAB®은 코드가 객체 속성에 액세스할 때 미리 정의된 이벤트를 트리거할 수 있습니다.
events | 이벤트 이름 |
notify | 이벤트가 발생했음을 리스너에 알림 |
addlistener | 이벤트 소스에 바인딩된 이벤트 리스너 생성 |
listener | 이벤트 소스에 바인딩하지 않고 이벤트 리스너 생성 |
event.hasListener | 이벤트에 대한 리스너가 있는지 확인 |
event.EventData | 이벤트 데이터의 기본 클래스 |
event.ClassInstanceEvent | Event data for InstanceCreated and InstanceDestroyed events |
event.listener | 리스너(Listener) 객체를 정의하는 클래스 |
event.PropertyEvent | 속성 이벤트의 데이터 |
event.proplistener | 속성 이벤트에 대한 리스너(Listener) 객체 정의 |
이벤트 및 리스너를 사용하여 메시지를 보내고 메시지에 응답할 수 있습니다.
이벤트는 등록된 모든 리스너에 알림을 브로드캐스트하고 이벤트 관련 데이터를 리스너 콜백 함수에 전달합니다.
다음 코드 예제에서는 이벤트와 리스너를 정의하는 방법을 보여줍니다.
Specify a list of classes that can be notified of a specific event.
Control access to events by setting event attributes.
Specify listener callbacks using function handles.
Errors in listener callbacks do not prevent execution of other listeners. However, the order of listener execution is not defined.
MATLAB manages the lifecycle of listeners. For greater control of listener lifecycle, constructor listener objects using the listener
method instead of addlistener
.
Determine If Event Has Listeners
You can determine if there are listeners defined for a specific event and event source.
MATLAB은 모든 속성에 대해 set 및 get의 사전/사후 이벤트를 정의합니다.
Assignment When Property Value Is Unchanged
Prevent the triggering of property events when values do not change using the property AbortSet
attribute.
Redefine the event data that MATLAB passes to listeners when an event is triggered.
Observe Changes to Property Values
Listeners can respond to changes in the value of properties using predefined property events.
Implement Property Set Listener
Listeners can respond to changes in property values before or after MATLAB assigns the value.
Techniques for Using Events and Listeners
This example shows how to enable and disable listener execution using context menus.
You can restore property listeners from the loadobj
method.