• 创建文本编辑输入框1:


    创建文本编辑输入框:这里多了个鼠标双击事件

    注意:创建文本编辑框时需要新建屏幕100,在屏幕100上用定义控制C元素画出 输入文本框定义名称:MYCONTAINER1

    *&---------------------------------------------------------------------*
    *& Report  ZTEST_CWBK
    *&
    *&---------------------------------------------------------------------*
    *&
    *&
    *&---------------------------------------------------------------------*
    
    REPORT  ztest_cwbk.
    CONSTANTS:
      line_length TYPE i VALUE 100.
    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(20) 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'.
    
    
      ENDMETHOD.
    
    
    ENDCLASS.
    
    
    
    
    START-OF-SELECTION.
      SET SCREEN '100'.
    *&---------------------------------------------------------------------*
    *&      Module  USER_COMMAND_0100  INPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    MODULE user_command_0100 INPUT.
      DATA str TYPE c.
      DATA sline(100) TYPE i.
      CASE ok_code.
        WHEN 'EXIT'.
          LEAVE TO SCREEN 0.
        WHEN 'BTT'.
      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                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
        IF sy-subrc <> 0.
          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          = 1
            error_cntl_init            = 2
            error_cntl_link            = 3
            error_dp_create            = 4
            gui_type_not_supported     = 5
            OTHERS                     = 6.
        IF sy-subrc <> 0.
          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
        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
  • 相关阅读:
    LeetCode 82,考察你的基本功,在有序链表中删除重复元素II
    golang | Go语言入门教程——结构体初始化与继承
    pandas | 使用pandas进行数据处理——DataFrame篇
    博弈论 | 详解搞定组合博弈问题的SG函数
    PCA算法 | 数据集特征数量太多怎么办?用这个算法对它降维打击!
    Python | 面试必问,线程与进程的区别,Python中如何创建多线程?
    Pytorch | 详解Pytorch科学计算包——Tensor
    通过Windows Visual Studio远程调试WSL2中的.NET Core Linux应用程序
    MSIL入门(二)通过对象看IL
    MSIL入门(一)C#代码与IL代码对比
  • 原文地址:https://www.cnblogs.com/caizjian/p/4360094.html
Copyright © 2020-2023  润新知