TEXT文本编辑框3 点击按钮添加文本至文本输入框
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 点击按钮添加文本至文本输入框的更多相关文章
- TEXT文本编辑框4 点击按钮读取文本框内容到内表
*&---------------------------------------------------------------------* *& Report ZTEST_CWB ...
- 【HTML5】页面点击按钮添加一行 删除一行 全选 反选 全不选
页面点击按钮添加一行 删除一行 全选 反选 全不选 页面效果图如下 html页面代码 <!DOCTYPE html> <html> <head> & ...
- input有许多,点击按钮使用form传递文本框的值
input有许多,点击按钮使用form传递文本框的值 <form name="form1" method="post" action="< ...
- js实现点击按钮时显示弹框,点击按钮及弹框以外的区域时隐藏弹框
转自https://blog.csdn.net/yimawujiang/article/details/86496936 问题:js实现点击按钮时显示弹框,点击按钮及弹框以外的区域时隐藏弹框? 方案一 ...
- 点击按钮添加一行,和本行的删除功能,序号变动,name属性更改
<!--html结构--> <div> <input type="button" value="添加一行" onclick=&qu ...
- FineUI 点击按钮添加标签页
<html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat=&quo ...
- GrideVlew提供点击按钮添加新数据,单击项目修改,长按删除功能
package com.example.wang.myapplication; import android.app.AlertDialog; import android.content.Dialo ...
- TEXT文本编辑框2
Result: When you double clicks on the TextEdit control nothing happens, since the flow-logic of the ...
- C#点击按钮添加标签
<asp:Button ID="button1" runat="server" Text="创建" onclick="But ...
随机推荐
- Java面试题集(1-50)
下面的内容是对网上原有的面试题集及答案进行了全面修订之后的内容(原来的题目有很多重复无用的题以及错误的答案),参照了JDK最新版本,删除了重复题目以及EJB2.x等无用内容,补充最新面试题.知识点巩固 ...
- CodeForces 385C Bear and Prime Numbers 素数打表
第一眼看这道题目的时候觉得可能会很难也看不太懂,但是看了给出的Hint之后思路就十分清晰了 Consider the first sample. Overall, the first sample h ...
- methanol 模块化的可定制的网页爬虫软件,主要的优点是速度快。
methanol模块化的可定制的网页爬虫软件,主要的优点是速度快. 下载:http://sourceforge.net/projects/methabot/?source=typ_redirect R ...
- zookeeper 之znode 节点
<pre name="code" class="html">使用 ls 命令来查看当前 ZooKeeper 中所包含的内容: [zk: 10.77. ...
- mysql 行锁排查
<pre name="code" class="html">mysql 锁表: 隔离级别使用RR: mysql> SELECT @@GLOBA ...
- [WPF源代码]QQ空间相册下载工具
放一个WPF源代码,源代码地址 http://download.csdn.net/detail/witch_soya/6195987 代码没多少技术含量,就是用WPF做的一个QQ空间相册下载工具,效果 ...
- 如何使用不同dll的相同namespace下的相同接口
问题: 程序里加载了2个dll,这2个dll里都声明了同样的命名空间(这个不违法),然后在这个同样的命名空间下,他俩又定义了同名的interface. 然后我程序里直接using这个命名空间,使用这个 ...
- container_of用法及实现
container_of 有的情况下,只知道 struct结构中莫个成员的指针,而需要知道整个struct的指针 (如网卡驱动里面,list) struct DDD { int a; ...
- asp.net 中将汉字转换成拼音
/// <summary> /// 获取汉字的全拼音 /// </summary> /// <param name="x">传汉字的字符串< ...
- maven setting配置
<?xml version="1.0" encoding="UTF-8"?> <!--Licensed to the Apache Softw ...