SAP Control framework系列(12)
1.1 更多的方法和事件
我们上面用到了几个方法,分别是:
SET_TEXT_AS_R3TABLE:这个方法把内表中的数据发送到text control中
SET_TEXT_AS_STREAM: 这个基本和SET_TEXT_AS_R3TABLE差不多
SET_REGISTERED_EVENTS:注册事件
下面我们再介绍几个常用的方法:
5.5.1 GET_REGISTERED_EVENTS
参数:
EVENTS Type CNTL_SIMPLE_EVENTS
这个方法从CL_GUI_CONTROL继承而来,没有重新定义,作用是得到当前已经注册的事件,小例子如下:
定义数据:
data: rg_events type CNTL_SIMPLE_EVENTS. |
定义方法:
class call_meth definition. public section. types: begin of t_texttab, line(255) type c, end of t_texttab. data: i_texttab type table of t_texttab. data: rg_events type CNTL_SIMPLE_EVENTS. methods: load_text, load_events. private section. data: indicator type c. methods: add_data importing ind type c. endclass. class call_meth implementation. method add_data. data: begin of rtab, e_name(50) type c, e_type(20) type c, end of rtab. data: itab like table of rtab. data: r_event type CNTL_SIMPLE_EVENT. case ind. when '1'. * Create internal table with texts APPEND 'This a method that fills the TextEdit control' TO i_texttab. APPEND 'with a text.' TO i_texttab. DO 10 TIMES. APPEND 'hallo world !' TO i_texttab. ENDDO. when '2'. call method text_editor->GET_REGISTERED_EVENTS importing events = rg_events. loop at rg_events into r_event. case r_event-eventid. when -601. rtab-e_name = 'EVENT_DOUBLE_CLICK'. when 2. when 0. when 1. when 5. when 6. when 3. rtab-e_name = 'EVENT_F1'. when others. endcase. if r_event-appl_event = space. rtab-e_type = 'System Event'. else. rtab-e_type = 'Application Event'. endif. append rtab to itab. endloop. call method text_editor->SET_TEXT_AS_STREAM exporting TEXT = itab. when others. endcase. endmethod. method load_text. call method add_data exporting ind = '1'. * Load TextEdit control with texts CALL METHOD text_editor->set_text_as_r3table EXPORTING table = i_texttab. IF sy-subrc > 0. * Display an error message EXIT. ENDIF. * All methods that operates on controls are transferred to the frontend * by a RFC calls. the method FLUSH is used to determine when this is don CALL METHOD cl_gui_cfw=>flush. IF sy-subrc > 0. * Display an error message ENDIF. endmethod. method load_events. call method add_data exporting ind = '2'. call method cl_gui_cfw=>flush. endmethod. endclass. |
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/190059/viewspace-476647/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/190059/viewspace-476647/