넥사크로 이벤트(parameter를 사용하자)

형아·2025년 1월 7일

Nexacro

목록 보기
2/18

버튼 텍스트 수정

  1. 버튼의 여백부분 클릭 + 클릭 (더블클릭 x)
  2. 단축키 f2
  3. 버튼 클릭 후 우측 Properties > 첫번째 아이콘 > text 부분 수정

:: 버튼 내 텍스트 줄바꿈 시, ctrl + Enter


이벤트

이벤트 함수 생성
1. 더블클릭
2. 클릭 > 우측 Properties > 네번째 아이콘 > onclick부분 값 입력후 enter

함수 입력

  1. alert
  • 스코프 (this) 반드시 표기
  • 여기서 this는 Form을 의미함
  • 즉, Form의 매서드 alert을 사용한다
this.Button00_onclick = function(obj:nexacro.Button,e:nexacro.ClickEventInfo){
	this.alert("hello");
};




2. log 찍기

  • 디버깅할 때 많이 쓸 거임
  • log는 Application 영역
  • nexacro.getApplication() : Application에 접근
  • .trace() : 로그 남기는 메서드
this.Button00_onclick = function(obj:nexacro.Button,e:nexacro.ClickEventInfo){
	this.alert("hello");
    
    nexacro.getApplication().trace("로그1");
};
this.Button00_onclick = function(obj:nexacro.Button,e:nexacro.ClickEventInfo){
	this.alert("hello");
    
    var objApp = nexacro.getApplication();
    objApp.trace("로그2");
};
  1. 버튼 속성 변경
  • Button이 Form에 있기 때문에 this 사용
  • .set_속성명() : 속성의 값 세팅하는 메서드
  • 값을 확인 할 때는 바로 속성명 기술
this.Button00_onclick = function(obj:nexacro.Button,e:nexacro.ClickEventInfo){
	this.alert("hello");
    
    nexacro.getApplication().trace("로그1");
    
    //세팅 : set_속성명
    this.Button00.set_text("그냥 안녕"); 
    
    //확인
    this.alert(this.Button00.text);
};

확인 방법

가운데 상단 돋보기 모양 (QuickView) 클릭 > 브라우저 선택


id 변경 시

기존 코드

this.Button00_onclick = function(obj:nexacro.Button,e:nexacro.ClickEventInfo){
	this.alert("hello");
    
    nexacro.getApplication().trace("로그1");
    
    //세팅 : set_속성명
    this.Button00.set_text("그냥 안녕"); 
    
    //확인
    this.alert(this.Button00.text);
};

하지만,
명명 규칙에 의해 버튼의 id명을 Button00 => btnHello로 바꿨다고 하자.
그렇다면 위의 코드는 다음과 같이 바꿔야 정상 작동 하게 된다.

this.Button00_onclick = function(obj:nexacro.Button,e:nexacro.ClickEventInfo){
	this.alert("hello");
    
    nexacro.getApplication().trace("로그1");
    
    //세팅 : set_속성명
    this.btnHello.set_text("그냥 안녕"); //수정
    
    //확인
    this.alert(this.btnHello.text); //수정
};

어느 세월에 id명을 하나하나 바꿀텐가?!


그래서,
한 번에 바꾸는 방법이 있다.


위의 함수 젤 첫 라인을 보면,
function에 obje 라는 파라미터 2개가 전달되는 것을 볼 수 있다.

여기서 obj 는 this.Button을 의미한다.

this.Button00_onclick = function(obj:nexacro.Button,e:nexacro.ClickEventInfo)

그래서 this.Button 대신에 obj를 사용하면,
id가 변경되어도 별 다른 수정 없이 적용가능하다.

this.Button00_onclick = function(obj:nexacro.Button,e:nexacro.ClickEventInfo){
	this.alert("hello");
    
    nexacro.getApplication().trace("로그1");
    
    //세팅 : set_속성명
    obj.set_text("그냥 안녕"); //수정
    
    //확인
    this.alert(obj.text); //수정
};

즉, Event에서 Script 작성 시, 파라미터 사용하기

profile
개발새발

0개의 댓글