이 번역 페이지는 최신 내용을 담고 있지 않습니다. 최신 내용을 영문으로 보려면 여기를 클릭하십시오.
이벤트
이벤트 정의 및 트리거하기. 이벤트에 응답하는 리스너 생성하기
이벤트는 객체와 관련하여 일부 변경이나 동작이 발생할 경우 브로드캐스트되는 알림입니다. 리스너는 특정 이벤트가 발생할 때 실행되는 함수를 정의합니다. 클래스는 이벤트를 정의하고 트리거할 수 있습니다. 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) 객체 정의 |
도움말 항목
이벤트와 리스너
- 이벤트 및 리스너 개요
이벤트 및 리스너를 사용하여 메시지를 보내고 메시지에 응답할 수 있습니다. - 이벤트 및 리스너 개념
이벤트는 등록된 모든 리스너에 알림을 브로드캐스트하고 이벤트 관련 데이터를 리스너 콜백 함수에 전달합니다. - 이벤트와 리스너 구문
다음 코드 예제에서는 이벤트와 리스너를 정의하는 방법을 보여줍니다. - Event Access List
Specify a list of classes that can be notified of a specific event. - 이벤트 특성
이벤트 특성을 설정하여 이벤트에 대한 액세스를 제어합니다.
리스너 구현하기
- 리스너 콜백 구문
함수 핸들을 사용하여 리스너 콜백을 지정합니다. - Callback Execution
Errors in listener callbacks do not prevent execution of other listeners. However, the order of listener execution is not defined. - Listener Lifecycle
MATLAB manages the lifecycle of listeners. For greater control of listener lifecycle, constructor listener objects using thelistener
method instead ofaddlistener
. - 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 propertyAbortSet
attribute.
이벤트와 리스너 샘플
- Define Custom Event Data
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. - Restore Listeners
You can restore property listeners from theloadobj
method.