In this exercise a function that loads the texts of an internal table into the text window, is implemented.

Steps:

Define anoterh pushbutton on the screen, that activates the method that fills the TextEdit control. Give itname PUSHBUTTON_IMPORT and function code IMP.

Define a form CREATE_TEXTS that carries out the text import.

Only changes to the code in example 2 is show.

Code:

*&---------------------------------------------------------------------*
*& Report ZTEST_CWBK
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT ztest_cwbk.
CONSTANTS:
line_length TYPE i VALUE .
DATA: ok_code LIKE sy-ucomm.
DATA:
* Create reference to the custom container
custom_container TYPE REF TO cl_gui_custom_container,
* Create reference to the TextEdit control
editor TYPE REF TO cl_gui_textedit,
repid LIKE sy-repid. ********************************************************************** * Impmenting events
**********************************************************************
DATA:
event_type() TYPE c, * Internal table for events that should be registred i_events TYPE cntl_simple_events, * Structure for oneline of the table wa_events TYPE cntl_simple_event.
*---------------------------------------------------------------------*
* CLASS lcl_event_handler DEFINITION
*---------------------------------------------------------------------* CLASS lcl_event_handler DEFINITION. PUBLIC SECTION. CLASS-METHODS: catch_dblclick FOR EVENT dblclick OF cl_gui_textedit IMPORTING sender.
ENDCLASS.
CLASS lcl_event_handler IMPLEMENTATION. METHOD catch_dblclick. * event_type = 'Event DBLCLICK raised'. * Reacting to the system event
call method cl_gui_cfw=>set_new_ok_code exporting new_code = 'SHOW'. ENDMETHOD. ENDCLASS. START-OF-SELECTION.
SET SCREEN ''.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
DATA str TYPE c.
DATA sline() TYPE i.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN .
WHEN 'IMP'.
* event_type = 'System dblclick'.
perform load_texts.
ENDCASE.
* Call the Dispacth method to initiate application event handling
* call method cl_gui_cfw=>Dispatch. ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MAIN100'.
IF editor IS INITIAL.
repid = sy-repid.
* Create obejct for custom container
CREATE OBJECT custom_container
EXPORTING
container_name = 'MYCONTAINER1'
EXCEPTIONS
cntl_error =
cntl_system_error =
create_error =
lifetime_error =
lifetime_dynpro_dynpro_link =
OTHERS = .
IF sy-subrc <> .
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Create obejct for the TextEditor control
CREATE OBJECT editor
EXPORTING
wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position = line_length
wordwrap_to_linebreak_mode = cl_gui_textedit=>true
parent = custom_container
EXCEPTIONS
error_cntl_create =
error_cntl_init =
error_cntl_link =
error_dp_create =
gui_type_not_supported =
OTHERS = .
IF sy-subrc <> .
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. * Link the event handler method to the event and the
* TextEdit control
SET HANDLER lcl_event_handler=>catch_dblclick FOR editor.
* Register the event in the internal table i_events
wa_events-eventid = cl_gui_textedit=>event_double_click.
* wa_events-appl_event = 'X'. "This is an application event
wa_events-appl_event = space. "This is a system event
append wa_events to i_events.
* Pass the table to the TextEdit control using method
* set_registred_events
call method editor->set_registered_events
exporting events = i_events.
ENDIF. ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Form LOAD_TEXTS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form LOAD_TEXTS .
TYPES:
BEGIN OF t_texttable,
line(line_length) TYPE c,
END OF t_texttable.
DATA
i_texttable TYPE TABLE OF t_texttable.
* Create internal table with texts
APPEND 'This a method that fills the TextEdit control' TO i_texttable.
APPEND 'with a text.' TO i_texttable.
DO TIMES.
APPEND 'hallo world !' TO i_texttable.
ENDDO.
* Load TextEdit control with texts
CALL METHOD editor->set_text_as_r3table
EXPORTING table = i_texttable.
IF sy-subrc > .
* 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 done.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc > .
* Display an error message
ENDIF. endform. " LOAD_TEXTS

TEXT文本编辑框3 点击按钮添加文本至文本输入框的更多相关文章

  1. TEXT文本编辑框4 点击按钮读取文本框内容到内表

    *&---------------------------------------------------------------------* *& Report ZTEST_CWB ...

  2. 【HTML5】页面点击按钮添加一行 删除一行 全选 反选 全不选

    页面点击按钮添加一行    删除一行   全选   反选  全不选 页面效果图如下 html页面代码 <!DOCTYPE html> <html> <head> & ...

  3. input有许多,点击按钮使用form传递文本框的值

    input有许多,点击按钮使用form传递文本框的值 <form name="form1" method="post" action="< ...

  4. js实现点击按钮时显示弹框,点击按钮及弹框以外的区域时隐藏弹框

    转自https://blog.csdn.net/yimawujiang/article/details/86496936 问题:js实现点击按钮时显示弹框,点击按钮及弹框以外的区域时隐藏弹框? 方案一 ...

  5. 点击按钮添加一行,和本行的删除功能,序号变动,name属性更改

    <!--html结构--> <div> <input type="button" value="添加一行" onclick=&qu ...

  6. FineUI 点击按钮添加标签页

    <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat=&quo ...

  7. GrideVlew提供点击按钮添加新数据,单击项目修改,长按删除功能

    package com.example.wang.myapplication; import android.app.AlertDialog; import android.content.Dialo ...

  8. TEXT文本编辑框2

    Result: When you double clicks on the TextEdit control nothing happens, since the flow-logic of the ...

  9. C#点击按钮添加标签

    <asp:Button ID="button1" runat="server" Text="创建" onclick="But ...

随机推荐

  1. 2014-7 Andrew Ng 自动化所报告听后感

    原文:http://blog.sina.com.cn/s/blog_593af2a70102uwhl.html 一早出发,8点20就赶到现场, 人越聚越多,Ng提前几分钟到达现场,掌声一片.    N ...

  2. BZOJ 3384: [Usaco2004 Nov]Apple Catching 接苹果( dp )

    dp dp( x , k ) = max( dp( x - 1 , k - 1 ) + *** , dp( x - 1 , k ) + *** ) *** = 0 or 1 ,根据情况 (BZOJ 1 ...

  3. ARM流水线(pipeline)

  4. 【转】centos安装memcached+php多服务器共享+session多机共享问题

    参考博文: centos安装memcached 源码安装 Yum安装Memcache Memcached内存分配优化及使用问题 <转>php+memcached 实现session共享 P ...

  5. USACO Runaround Numbers 模拟

    根据题意的 Runaround 规则去找比当前数大的最近的一个 Runaround数字 模拟题~ Source code: /* ID: wushuai2 PROG: runround LANG: C ...

  6. Chapter 1.简单工厂模式

    该篇文章通过一个写计算器控制台程序,来导入文章主题. 首先,要注意代码规范,变量命名有意义,不能随意用A,B,C;    功能要封装好,不要写在一个主函数里,另外要考虑后期需求的更改,如果出现多个函数 ...

  7. hibernate对应的annocation版本

    Hibernate Compatibility Matrix Package Version Core Annotations EntityManager Validator Search Shard ...

  8. Shell之sed命令

    sed用于一次性处理所有的编辑任务,尤为高效,为用户节省了大量的时间,sed适用于以下三种场合: 1.编辑相对交互文本编辑器而言太大的文件: 2.编辑命令太复杂,在交互式文本编辑器中难以输入的情况: ...

  9. android的fragments管理

    FragmentManager 为了管理Activity中的fragments,需要使用FragmentManager. 为了得到它,需要调用Activity中的getFragmentManager( ...

  10. 以前学习cisco ccna 课程的时候做的笔记

    由于学习的专业是计算机网络技术,可是在上学的时候,并没有学习到多少网络知识,所以为了对得起学的专业,在06年工作的时候,在哈工大银河教育报了个ccna的班,两个星期的课程,每天上那么几个小时. 结果依 ...