精华内容
下载资源
问答
  • textEdit

    2019-09-21 13:07:33
    textEdit可以添加背景图片、渐变色、文字颜色、大小等等 <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools=...

    textEdit可以添加背景图片、渐变色、文字颜色、大小等等

     

     

    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:context=".MainActivity">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
        >
            <!--设置字号为20pt,在文本末尾绘制图片-->
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Hello World!"
                android:textSize="20pt"
                android:drawableEnd="@mipmap/ic_launcher"
                android:drawableRight="@mipmap/ic_launcher"
            />
            <!--设置中间省略,所有字母大写-->
            <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:singleLine="true"
                    android:ellipsize="middle"
                    android:textAllCaps="true"
                    android:text="学习Android学习Android学习Android学习Android学习Android学习Android学习Android"
            />
            <!--设置文字颜色、大小、使用阴影-->
            <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="测试文字"
                    android:shadowColor="#00f"
                    android:shadowDx="10.0"
                    android:shadowDy="8.0"
                    android:shadowRadius="3.0"
                    android:textColor="#ff0"
                    android:textSize="18pt"
            />
            <!--设置可勾选文本-->
            <CheckedTextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="可勾选的文本"
                    android:checkMark="@drawable/ok"
            />
            <!--指定背景-->
            <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="带边框的文本"
                    android:textSize="24pt"
                    android:background="@drawable/bg_border"
            />
            <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="圆角边框,渐变背景"
                    android:textSize="24pt"
                    android:background="@drawable/bg_border2"
            />
        </LinearLayout>
    </ScrollView>
    activaty_main.xml

     

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle">
    <!--设置背景色为透明-->
        <solid android:color="#0000"/>
        <!--设置红色边框-->
        <stroke android:width="2dp" android:color="#f00"/>
    </shape>
    bg_border
    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
           android:shape="rectangle">
      <!--指定4个圆角的半径-->
        <corners
                android:topLeftRadius="20dp"
                android:topRightRadius="10dp"
                android:bottomLeftRadius="20dp"
                android:bottomRightRadius="10dp"
        />
        <!--指定边框线条的宽度和颜色-->
        <stroke
            android:color="#f0f"
            android:width="4px"/>
        <!--指定渐变色-->
        <gradient
            android:startColor="#f00"
            android:centerColor="#0f0"
            android:endColor="#00f"
            android:type="sweep"/>
    </shape>
    bg_border2

     

    转载于:https://www.cnblogs.com/superxuezhazha/p/11474547.html

    展开全文
  • TextEdit

    2007-11-28 09:28:37
    最初我用C语言直接呼叫API编写的文本编辑器。存在几处BUG。有待于修复。
  • pyqt5 textEdit、lineEdit操作

    万次阅读 多人点赞 2019-05-15 08:59:24
    1.定义一个textEdit/lineEdit:(lineEdit只需要将代码中的QTextEdit改为QLineEdit) self.textEdit = QtWidgets.QTextEdit(Dialog) self.textEdit.setGeometry(QtCore.QRect(70, 90, 171, 391)) self.textEdit....

    1.定义一个textEdit/lineEdit:(lineEdit只需要将代码中的QTextEdit改为QLineEdit)

        self.textEdit = QtWidgets.QTextEdit(Dialog)
        self.textEdit.setGeometry(QtCore.QRect(70, 90, 171, 391))
        self.textEdit.setObjectName("textEdit")
        self.textEdit.setReadOnly(True)#设置为只读,即可以在代码中向textEdit里面输入,但不能从界面上输入,没有这行代码即可以从界面输入
    

    2.从代码中将字符串显示到textEdit:

    str='要显示的字符串'
    self.textEdit.setText(str)
    

    3.追加字符串:

     str='要显示的字符串'
     self.textEdit_2.append(str)
    

    4.显示数字到textEdit:数字必须要转换成字符串

    count=10
    str=str(count)
    self.textEdit.setText(str)
    

    5.读取textEdit中的文字:textEdit和LineEdit中的文字读取方法是不一样的

    str1 = self.textEdit.toPlainText()
    #textEdit 用toPlainText()方法
    #linEdit 直接用self.lineEdit.text()即可获取
    
    展开全文
  • dev textedit绑定gridview
  • textedit设置水印Compared to Notepad, TextEdit is far more fully-featured. We have to deliberately “dumb it down” in order to work to our purposes. First, run TextEdit. You can find it under System /...

    textedit设置水印

    Textedit New Document preferencesCompared to Notepad, TextEdit is far more fully-featured. We have to deliberately “dumb it down” in order to work to our purposes.

    First, run TextEdit. You can find it under System / Applications / TextEdit in most installations of OS X. (Ensure that you are running TextEdit 1.7 or higher: 1.6 has a bug in saving .html files)

    首先,运行TextEdit。 在大多数OS X安装中,都可以在“ 系统” /“应用程序” /“ TextEdit”下找到它。(确保您运行的是TextEdit 1.7或更高版本:1.6在保存.html文件时存在错误)

    You will find that by default TextEdit appears as a simplified word processor, with rulers, margins, tab indents, alignment control, etc. For our purposes, we want to make sure that TextEdit starts a new document without these features.

    您会发现默认情况下,TextEdit显示为简化的文字处理程序,带有标尺,边距,制表符缩进,对齐控件等。出于我们的目的,我们要确保TextEdit在没有这些功能的情况下启动新文档。

    In the menu bar of TextEdit, go to File / Preferences. (Alternatively, and faster: Press Command-,. That is the shortcut to preferences in most OS X applications, with a few exceptions).

    在TextEdit的菜单栏中,转到文件/首选项 。 (或者,更快:按Command-,。这是大多数OS X应用程序中首选项的快捷方式,只有少数例外)。

    In the Preferences dialog, under the New Document option, change the settings to what is shown in the image to the right. (Note that the plain text font setting shown may be a little large for your purpose – feel free to change the font and size to whatever you find the most legible).

    在“ 首选项”对话框的“ 新建文档”选项下,将设置更改为右侧图像中显示的设置。 (请注意,显示的纯文本字体设置可能会因您的目的而有些大-可以随意将字体和大小更改为您最清楚看到的字体和大小)。

    Then, under the Open and Save option of the Preferences pane for TextEdit, change the settings to what you see to the right:

    Textedit Open and Save preferences

    然后,在TextEdit的“ 首选项”窗格的“ 打开和保存”选项下,将设置更改为您在右侧看到的设置:

    Close the Preferences pane (fastest method: Command-W).

    关闭“ 首选项”窗格(最快的方法: Command-W )。

    Note that the current document is unchanged. You have changed preferences for future documents written in TextEdit, but not the currently open one. Close the current document (again, fastest option: Command-W, which always closes the active window).

    请注意,当前文档未更改。 您已更改了用TextEdit编写的将来文档的首选项,但没有更改当前打开的首选项。 关闭当前文档(再次,最快的选项: Command-W ,它始终关闭活动窗口)。

    Create a new document (fastest method: Command-N). It should be a blank page, free of rulers, alignment controls and other features.

    创建一个新文档(最快的方法: Command-N )。 它应该是空白页,没有标尺,对齐控件和其他功能。

    翻译自: https://thenewcode.com/126/Tool-Setup-TextEdit

    textedit设置水印

    展开全文
  • matlab开发-TextEdit

    2019-11-15 06:17:46
    matlab开发-TextEdit。类似记事本的简单文本编辑器
  • TextEdit Control

    2019-02-08 14:36:05
    TextEdit ControlTIP: Use SE75 to create your own custom text ID for SAVE_TEXT objectExample 1: Creating the TextEd...
    TextEdit Control
    TIP: Use SE75 to create your own custom text ID for SAVE_TEXT object
    1. Example 1: Creating the TextEdit control

    2. Example 2: Event handling - Application event

    3. Example 3: Event handling - System event

    4. Example 4: Calling a methods of the control

    5. Example 5: Responding to an event

    6. Example 6: Protect a line in the TextEdit control and the importance of FLUSH

    7. Example 7: Using multiple controls

    See the whole program code

    Example 1: Creating the TextEdit control

    This is a simple example of how to implement a text edit control.

    Steps

    1. Create a report
    2. In the start of selection event add: SET SCREEN '100'.
    3. Create screen 100
    4. Place a custom control on the screen by choosing the custom control icon which can be recognized by the letter 'C', and give it the name MYCONTAINER1.
    5. To be able to exit the program, add a pushbutton with the function code EXIT.
    6. In the elements list enter the name OK_CODE for the element of type OK.

    The code

    REPORT sapmz_hf_controls1 .
    CONSTANTS:
      line_length TYPE i VALUE 254.
    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.
    START-OF-SELECTION.
      SET SCREEN '100'.
    *---------------------------------------------------------------------*
    
    *       MODULE USER_COMMAND_0100 INPUT                                *
    
    *---------------------------------------------------------------------*
    
    MODULE user_command_0100 INPUT.
      CASE ok_code.
        WHEN 'EXIT'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&---------------------------------------------------------------------*
    
    *&      Module  STATUS_0100  OUTPUT
    
    *&---------------------------------------------------------------------*
    
    MODULE status_0100 OUTPUT.
    * The TextEdit control should only be initialized the first time the
    
    * PBO module executes
    
      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.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT

    The result

    texted1.jpg

    Example 2: Event handling - Application event

    There are 2 types of events:

    • System events. These events are triggerede irrespective of the screen flow-logic.
    • Application events. The PAI module is processed after an event. The method CL_GUI_CFW=>DISPATCH must be called to initiate event handling

    In this example an application event is added to the program in example 1. New code is marked with red.

    Steps:

    1. Create an input/output field on screen 100, where the event type can be output. Name it EVENT_TYPE

    The code:

    REPORT sapmz_hf_controls1 .
    CONSTANTS:
      line_length TYPE i VALUE 254.
    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.
      CLEAR wa_events. refresh i_events.
      SET SCREEN '100'.
    
     
    *---------------------------------------------------------------------*
    
    *       MODULE USER_COMMAND_0100 INPUT                                *
    
    *---------------------------------------------------------------------*
    
    MODULE user_command_0100 INPUT.
      CASE ok_code.
        WHEN 'EXIT'.
          LEAVE TO SCREEN 0.
        WHEN OTHERS.
    *   Call the Dispacth method to initiate application event handling
    
        call method cl_gui_cfw=>Dispatch.
    
     
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&---------------------------------------------------------------------*
    
    *&      Module  STATUS_0100  OUTPUT
    
    *&---------------------------------------------------------------------*
    
    MODULE status_0100 OUTPUT.
    * The TextEdit control shoul only be initialized the first time the
    
    * PBO module executes
      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

    Result:

    When you double click on the TextEdit control, the input/ouput field should show the text: Event DBLCLICK

    Example 3: Event handling - System event

    System events are passed irrespective of the flow-logic of the screen. To implement a system event change the code from example 2 as follows:

    Code:
    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'.
    
    
     

    MODULE user_command_0100 INPUT.
      CASE ok_code.
       code.........
        WHEN 'SHOW'.
          event_type = 'System dblclick'.
        WHEN OTHERS.
    *----    call method cl_gui_cfw=>Dispatch.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT

    MODULE status_0100 OUTPUT.
     Code ................
    *---    wa_events-appl_event = 'X'. "This is an application event
    
        wa_events-appl_event = space. "This is a system event
    
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT

    Result:

    When you double clicks on the TextEdit control nothing happens, since the flow-logic of the screen an dthe fielde transport is ignore.

    Example 4: Calling methods of the control

    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:

    MODULE user_command_0100 INPUT.
      CASE ok_code.
    
       code.........
    
        WHEN 'IMP'.
    
          perform load_texts. 
    
      ENDCASE.
    
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&---------------------------------------------------------------------*
    
    *&      Form  load_texts
    
    *&---------------------------------------------------------------------*
    
    * This form creates an internal table with texts. The the contents of
    
    * the table is instered into the TextEdit control using method
    
    * set_text_as_r3table
    
    *----------------------------------------------------------------------*
    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 10 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 > 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 done.
      CALL METHOD cl_gui_cfw=>flush.
      IF sy-subrc > 0.
    *   Display an error message
      ENDIF.
    ENDFORM.                    " create_texts

    Example 5: Responding to an event

    When you double click on a text line in the TextEdit control, you want it to be prefixed with a '*'.

    The line number of the TextEdit control that is double clicked, is retreived using method GET_SELECTION_POS. The internal text table is reloaded froim the TextEdit control with method GET_TEXT_AS_R3TABLE. The position of the double click in the TextEdit control is used to find the entry in the table, and the entry is prefixed with '*' and loaded into the TextEdit control again.

    The program should be changed so that the internal table i_texttable is global, and a global flag g_loaded added. The load of the table should be moved to the PBO module. The changes in thje code are marked with red. The whole program now looks like this:

    Code

    REPORT sapmz_hf_controls1 .
    CONSTANTS:
      line_length TYPE i VALUE 254.
    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.
    **********************************************************************
    
    * Utillity table to load texts
    
    **********************************************************************
    TYPES:
    
       BEGIN OF t_texttable,
    
         line(line_length) TYPE c,
    
       END OF t_texttable.
    DATA:
    
      i_texttable TYPE TABLE OF t_texttable,
    
      g_loaded(1) TYPE c.
    
     
    **********************************************************************
    
    * 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.
        DATA:
          from_line TYPE i,
          from_pos  TYPE i,
          to_line TYPE i,
          to_pos TYPE i,
          wa_texttable TYPE t_texttable.
    * Used for the sytem event
      call method cl_gui_cfw=>set_new_ok_code
        exporting new_code = 'SHOW'.
    * Read the position of the double click
        CALL METHOD sender->get_selection_pos
    
          IMPORTING
    
             from_line = from_line
    
             from_pos  = from_pos
    
             to_line   = to_line
    
             to_pos    = to_pos.
    *   Texts in the TextEdit control can have been changed, so
    
    *   first reload text from the control into the internal
    
    *   table that contains text
        IF NOT g_loaded IS INITIAL.
    
          CALL METHOD sender->get_text_as_r3table
    
               IMPORTING table = i_texttable.
    
    *   Read the line of the internal table that was clicked
          READ TABLE i_texttable INDEX from_line INTO wa_texttable.
    
          IF sy-subrc <> 0.
    
            EXIT.
    
          ENDIF.
          IF wa_texttable+0(1) CS '*'.
    
            SHIFT wa_texttable.
    
          ELSEIF wa_texttable+0(1) NS '*'.
    
            SHIFT wa_texttable RIGHT.
    
            wa_texttable+0(1) = '*'.
    
          ENDIF.
    
          modify i_texttable from wa_texttable index from_line.
    *     Reload texts from h einternal table
          perform load_texts.
        ENDIF.
      ENDMETHOD.
    ENDCLASS.
    
     
    START-OF-SELECTION.
      CLEAR wa_events.
      REFRESH: i_events.
      SET SCREEN '100'.
    *---------------------------------------------------------------------*
    
    *       MODULE USER_COMMAND_0100 INPUT                                *
    
    *---------------------------------------------------------------------*
    MODULE user_command_0100 INPUT.
      CASE ok_code.
        WHEN 'EXIT'.
          LEAVE TO SCREEN 0.
        WHEN 'SHOW'.
          event_type = 'System dblclick'.
        WHEN 'IMP'.
          PERFORM Load_texts.
        WHEN OTHERS.
    *    CALL METHOD cl_gui_cfw=>dispatch. "Not used for system events
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&---------------------------------------------------------------------*
    
    *&      Module  STATUS_0100  OUTPUT
    
    *&---------------------------------------------------------------------*
    MODULE status_0100 OUTPUT.
    * The TextEdit control shoul only be initialized the first time the
    
    * PBO module executes
      IF editor IS INITIAL.
        repid = sy-repid.
    *   Create object 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
        wa_events-appl_event = space. "This is a system event
        APPEND wa_events TO i_events.
    *   Pass the table to the TextEdit control uding method
    
    *   set_registred_events
        CALL METHOD editor->set_registered_events
           EXPORTING events = i_events.
    * Create internal table with texts taht can be uploaded to
    
    * the TextEdit control
      APPEND 'This a method that fills the TextEdit control' TO i_texttable.
        APPEND 'with a text.' TO i_texttable.
        DO 10 TIMES.
          APPEND 'hallo world !' TO i_texttable.
        ENDDO.
    
     
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&---------------------------------------------------------------------*
    
    *&      Form Load_texts
    
    *&---------------------------------------------------------------------*
    
    * This form loads the lines of the internal table i_texttable into
    
    * the TextEdit control
    
    *----------------------------------------------------------------------*
    FORM Load_texts.
    * Load TextEdit control with texts
      CALL METHOD editor->set_text_as_r3table
        EXPORTING table = i_texttable.
      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
    
    * done.
      CALL METHOD cl_gui_cfw=>flush.
      IF sy-subrc > 0.
    *   Display an error message
      ENDIF.
      g_loaded = 'X'.
    ENDFORM.                    " create_texts

    Example 6: Protect a line in the TextEdit control and the importance of FLUSH

    All methods that operates on controls are transfered to the fronend by RFC calls. The FLUSH method is used to synchronize control execution and the frontend. This is very important when working e.g. with export parameters from a method, as the parmeters will not be correct before the FLUSH method has been called.

    The example below portects selected lines in the TextEdit and uses FLUSH to ensure that the correct parameters are returned from method GET_SELECTION_POS.

    Note: Instead of using method PROTECT_LINES, the method PROTECT_SELECTION could be used. This method does not need line numbers or a FLUSH statement

    Steps

    • Add a new pushbutton to the screen with the function code PROTECT.

    Code

    Add the following code to the example:

    * Global variables
    
    DATA:
    
       from_idx TYPE i,
    
       to_idx TYPE i,
    
       index TYPE i.
    
    MODULE user_command_0100 INPUT.
    
      CASE ok_code.
    
        code.......................
    
        WHEN 'PROTECT'.
    
          PERFORM protect.
    
    
    
    .    .......................
    
      ENDCASE.
    
    *&---------------------------------------------------------------------*
    
    *&      Form  protect
    
    *&---------------------------------------------------------------------*
    
    * Protects marked lines in a TextEdit control
    
    *----------------------------------------------------------------------*
    FORM protect.
    * Determine the area selected by the user
      CALL METHOD editor->get_selection_pos
         IMPORTING
           from_line = from_idx
           to_line   = to_idx
         EXCEPTIONS
           error_cntl_call_method = 1.
    * Synchronize execution in the control with the ABAP program.
    
    * Without this synchronization the variables from_idx and
    
    * to_idx will have obsolutete values (The initial value for
    
    * both, are 0)
      CALL METHOD cl_gui_cfw=>flush.
      IF sy-subrc > 0.
    * Errormessage: Error in flush
      ENDIF.
    * Protect the selected lines
      IF to_idx > from_idx.
        to_idx = to_idx - 1.
      ENDIF.
      CALL METHOD editor->protect_lines
        EXPORTING
          from_line = from_idx
          to_line   = to_idx.
    * The PROTECT_SELECTION method could be used instead, eliminating the
    
    * need of line numbers and the last FLUSH
    
    
     
    * call method editor->protect_selection.
    * Flush again to protect immidiately
    
      CALL METHOD cl_gui_cfw=>flush.
      IF sy-subrc > 0.
    * Errormessage: Error in flush
      ENDIF.
    
     
    ENDFORM.                    " protect

    Example 7: Using multiple controls

    In this example a second TextEdit control will be added to the screen. The new TextEdit control will be designed to act as a clipboard for short texts.

    Steps:

    • Add a new container to the screen and name it MYCONTAINER2.

    Code:

    Insert global datadeclaration:

    **********************************************************************
    
    * Implementing a second Scratch TextEdit control
    
    **********************************************************************
    
    DATA:
    
      scratch            TYPE REF TO cl_gui_textedit,
    
      custom_container2  TYPE REF TO cl_gui_custom_container.
    

    Insert the following code in the PBO module:

    *------------------------------------------------------
    
    * The SCRATCH TextEdit control
    
    *------------------------------------------------------
    
      IF scratch IS INITIAL.
    *   Create obejct for custom container2
        CREATE OBJECT custom_container2
          EXPORTING
            container_name              = 'MYCONTAINER2'
          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 SCRATCH TextEditor control
        CREATE OBJECT scratch
          EXPORTING
             parent         = custom_container2
             wordwrap_mode  =
                    cl_gui_textedit=>wordwrap_at_windowborder
            wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
    *   Remove the staus bar
        CALL METHOD scratch->set_statusbar_mode
          EXPORTING statusbar_mode = cl_gui_textedit=>false.
      ENDIF.

    Result:

    texted2.jpg

    来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/190059/viewspace-476536/,如需转载,请注明出处,否则将追究法律责任。

    转载于:http://blog.itpub.net/190059/viewspace-476536/

    展开全文
  • 在JavaMe连载(3)-也说MVC设计模式 一文中提到了一个TextEdit类,但没有给出具体实现,TextEdit是采用GameCanvas绘制的文本编辑器。本文结合实例给出实现的方法。
  • QT TextEdit控件

    千次阅读 2020-10-22 23:37:55
    本文详细的介绍了TextEdit控件的各种操作,例如:获取内容、输入控件字符、保持在最后一行添加(自动滚屏)、定时关闭、添加数据换行、向鼠标位置插入一行字符、设置字体颜色属性等操作。 本文作者原创,转载请附上...
  • QmlTextEdit接受拖放QmlTextEditDrop.7z
  • mac textedit TextEdit is a simple text editor that comes standard on every Apple Macintosh computer. By following a few simple steps, you can use the TextEdit program to create and save ...
  • QmlTextEdit带滚动条QmlTextEditScrollBar.7z
  • TextEdit控件属性的AutoHeight属性设置为False后即可自由调节 一、选中TextEdit控件 二、查看TextEdit查看属性且设置 设置TextEdit属性的AutoHeight为False 三、自由设置TextEdit的高度大小 调节...
  • self.textEdit = QtGui.QTextEdit(slef) 1.设置背景颜色 self.textEdit.setStyleSheet("background:blue") 2.设置背景图 self.textEdit.setStyleSheet("background-image:url(timg.jpg)") 3.设置文字背景颜色 ...
  • 1.定义一个textEdit/lineEdit:(lineEdit只需要将代码中的QTextEdit改为QLineEdit) self.textEdit = QtWidgets.QTextEdit(Dialog) self.textEdit.setGeometry(QtCore.QRect(70, 90, 171, 391)) self.textEdit...
  • 本文实例展示了DevExpress实现为TextEdit设置水印文字的方法,是一个很实用的技巧。分享给大家供大家参考。 关键代码如下: public static void SetWatermark(this TextEdit textEdit, string watermark) { ...
  • QML之TextEdit

    2019-10-08 13:55:43
    TextEdit显示一个可编辑的,有格式的文本框。它也可以显示明文和富文本。例如:TextEdit { width: 240 text: "<b>Hello</b> <i>World!</i>" font.family: "Helvetica" font.pointSize: 20 ...
  • Qt之textEdit总结

    2021-06-05 11:41:45
    textedit->toPlainText():获取普通文本。 QString str = ui->textedit->toHtml():获取富文本,即获取的是HTML字符串。 ui->textedit->setPlainText ( "123" ):设置普通文本。 ui->textedit->...
  • self.textEdit_6.moveCursor(QTextCursor.End) 例子: self.textEdit_6.setPlainText(Hello World) 以上这篇PYQT5设置textEdit自动滚屏的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家...
  • 摘要:Delphi源码,界面编程,RTF,编辑器 Delphi TextEdit 仿RTF编辑器程序,可实现文本对齐、编辑、字体设置、文件保存、打英窗体排列方式等,比记事本高级些。 运行环境:Windows/Delphi7
  • TextEdit 乱码

    千次阅读 2014-11-03 16:17:15
    1. 打开mac系统的TextEdit,然后在左上角那个菜单里面,选择 文本编辑--偏好设置。 2. 在偏好设置中选择第二个标签页(打开和存储),选择"纯文本文件编码"中的"打开文件"和存储文件"修改成为"中文(GB 18030)",就...
  • 请教一下,TextEdit显示负数并在右边停靠时,怎么负数的“负号”跑到右边去了? 效果如图:左边一个正常的TextEdit,右边一个设置了RightToLeft=true;请问还需要设置其他属性吗? ![TextEdit显示异常]...
  • Qt:textEdit转PDF和打印

    2019-07-16 22:11:02
    适用于mac系统,可实现textEdit中内容转为PDF和打印预览功能。
  • Window { visible: true width: 640 height: 480 title: qsTr(Hello World) ... TextEdit { id: textEdit text: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  • DEVexpress 的TextEdit控件

    2016-05-24 03:10:38
    DEVexpress 的TextEdit控件如何设置内容居中对齐
  • QmlTextEdit接受拖放

    2017-10-20 11:36:31
    TextEdit中增加DropArea TextEdit{ id: textEdit height: 300 width: parent.width DropArea{ anchors.fill: parent onDropped: { if (dr

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 13,632
精华内容 5,452
关键字:

textedit