Progress
Language Reference


CLIPBOARD System Handle

Interfaces
OS
SpeedScript
All
All
Yes

A handle to the system clipboard widget. The CLIPBOARD handle allows you to implement interactions that allow the user to transfer data between Progress field-level widgets, or between Progress field-level widgets and the widgets of other applications running on the system. Progress can interpret the data read from or written to the system clipboard widget as a single item or as a group of multiple items. These data transfers are typically invoked as cut, copy, and paste operations.

SYNTAX

CLIPBOARD [ :attribute ] 

attribute

An attribute of the clipboard widget. This table lists the supported attributes.

Attribute
Type
Readable
Setable
CHARACTER
INTEGER
LOGICAL
INTEGER
CHARACTER
CHARACTER

EXAMPLES

The following code fragment implements cut, copy, and paste operations for the EM_Cut, EM_Copy, and EM_Paste items on the EditMenu menu. It uses the FOCUS handle to reference the widget that has the current input focus.

Note that the fragment tests the widget type of the FOCUS widget in two instances: once when EditMenu is opened during the MENU-DROP event to determine what clipboard operations are valid for the widget, and once again when a clipboard operation is chosen from the menu to determine how the operation is executed for the widget. During the MENU-DROP event, if a particular operation is valid for the FOCUS widget the menu item for that operation is enabled. Otherwise, it is disabled.

During the CHOOSE event for a n enabled menu item, the fragment executes the corresponding clipboard operation in a way that accounts for the unique features of the FOCUS widget. For example, the copy operation (EM_Copy) copies the selected text from an editor widget, copies the label text from a radio set item, and copies a composed true or false message for a toggle box. Your own implementation of these operations for the same widgets can be quite different.

For a complete description of this example, see the chapter on the system clipboard in the Progress External Program Interfaces manual.

DEFINE VARIABLE Stat AS LOGICAL.
            .
            .
            .
ON MENU-DROP OF MENU EditMenu DO:
    IF FOCUS:TYPE = "EDITOR" THEN DO:
       MENU-ITEM EM_Cut:SENSITIVE IN MENU EditMenu =
          IF  LENGTH(FOCUS:SELECTION-TEXT) > 0
          THEN TRUE
          ELSE FALSE.
       MENU-ITEM Em_Copy:SENSITIVE IN MENU EditMenu =
          IF  LENGTH(FOCUS:SELECTION-TEXT) > 0
          THEN TRUE
          ELSE FALSE.
       MENU-ITEM EM_Paste:SENSITIVE IN MENU EditMenu =
          IF CLIPBOARD:NUM-FORMATS > 0 
          THEN TRUE 
          ELSE FALSE.
    END.
    ELSE IF FOCUS:TYPE = "RADIO-SET"      OR 
            FOCUS:TYPE = "SELECTION-LIST" OR
            FOCUS:TYPE = "SLIDER"         OR
            FOCUS:TYPE = "TOGGLE-BOX" THEN DO:
       MENU-ITEM EM_Cut:SENSITIVE IN MENU EditMenu = FALSE.
       MENU-ITEM Em_Copy:SENSITIVE IN MENU EditMenu = TRUE.
       MENU-ITEM Em_Paste:SENSITIVE IN MENU EditMenu = FALSE.
    END.
    ELSE IF FOCUS:TYPE = "FILL-IN" THEN DO:
       MENU-ITEM EM_Cut:SENSITIVE IN MENU EditMenu =
          IF LENGTH(FOCUS:SCREEN-VALUE) > 0
          THEN TRUE
          ELSE FALSE.
       MENU-ITEM Em_Copy:SENSITIVE IN MENU EditMenu =
          IF LENGTH(FOCUS:SCREEN-VALUE) > 0
          THEN TRUE
          ELSE FALSE.
       MENU-ITEM EM_Paste:SENSITIVE IN MENU EDitMenu =
          IF CLIPBOARD:NUM-FORMATS > 0 
          THEN TRUE 
          ELSE FALSE.
    END.
    ELSE DO:
        MENU-ITEM EM_Cut:SENSITIVE IN MENU EditMenu = FALSE.
        MENU-ITEM EM_Copy:SENSITIVE IN MENU EditMenu = FALSE.
        MENU-ITEM EM_Paste:SENSITIVE IN MENU EditMenu = FALSE.
    END.
END. /* ON MENU-DROP IN EditMenu */ 
ON CHOOSE OF MENU-ITEM EM_Cut IN MENU EditMenu DO:
    IF FOCUS:TYPE = "EDITOR" THEN DO:
        IF FOCUS:SELECTION-START <> FOCUS:SELECTION-END THEN DO:
            CLIPBOARD:VALUE = FOCUS:SELECTION-TEXT.
            Stat = FOCUS:REPLACE-SELECTION-TEXT("").
        END.
        ELSE DO:
            CLIPBOARD:VALUE = FOCUS:SCREEN-VALUE.
            FOCUS:SCREEN-VALUE = "".
        END.
    END.
    ELSE DO: /* For FILL-IN */
        CLIPBOARD:VALUE = FOCUS:SCREEN-VALUE.
        FOCUS:SCREEN-VALUE = "".
    END.
END. /* ON CHOOSE OF MENU-ITEM EM_Cut */

ON CHOOSE OF MENU-ITEM EM_Copy IN MENU EditMenu DO:
    IF FOCUS:TYPE = "EDITOR" THEN
        IF FOCUS:SELECTION-START <> FOCUS:SELECTION-END THEN
            CLIPBOARD:VALUE = FOCUS:SELECTION-TEXT.
        ELSE 
            CLIPBOARD:VALUE = FOCUS:SCREEN-VALUE.
    ELSE IF FOCUS:TYPE = "RADIO-SET" THEN
        CLIPBOARD:VALUE = ENTRY(LOOKUP(FOCUS:SCREEN-VALUE, 
                                       FOCUS:RADIO-BUTTONS) - 1, 
                                FOCUS:RADIO-BUTTONS).
    ELSE IF FOCUS:TYPE = "TOGGLE-BOX" THEN
        IF FOCUS:SCREEN-VALUE = "yes" THEN
            CLIPBOARD:VALUE = FOCUS:LABEL + " selected.".
        ELSE
            CLIPBOARD:VALUE = FOCUS:LABEL + " not selected.".
    ELSE /* For FILL-IN */ 
        CLIPBOARD:VALUE = FOCUS:SCREEN-VALUE.
END. /* ON CHOOSE OF MENU-ITEM EM_Copy */

ON CHOOSE OF MENU-ITEM EM_Paste IN MENU EditMenu DO:
    IF FOCUS:TYPE = "EDITOR" THEN DO:
        IF FOCUS:SELECTION-START <> FOCUS:SELECTION-END THEN
            Stat = FOCUS:REPLACE-SELECTION-TEXT(CLIPBOARD:VALUE).
        ELSE 
            aResult = FOCUS:INSERT-STRING(CLIPBOARD:VALUE).
    END.
    ELSE /* For FILL-IN */
        FOCUS:SCREEN-VALUE = CLIPBOARD:VALUE.
END. /* ON CHOOSE OF MENU-ITEM EM_Paste */
            .
            .
            . 

The following r-clpmul.p procedure demonstrates interaction with the clipboard using multiple items. The procedure copies out four rows of five numbers to the clipboard. It first displays the clipboard data as a single item, and then as a list of multiple items.

As a further demonstration of how the CLIPBOARD handle works with multiple items, try the following experiment:

  1. Run the procedure, and at the pause, paste the result into an edit tool in your window system, such as Notepad on Windows.
  2. You may have to select and copy text in the edit tool to activate the system clipboard before running the procedure.
  3. Modify the text in the edit tool, leaving at least one tab or newline character, and copy it back to the clipboard from the edit tool.
  4. Respond to the pause in the procedure to see how the modified clipboard data is displayed.
  5. r-clpmul.p
      DEFINE VARIABLE i AS INTEGER.
      DEFINE VARIABLE ClipBuffer AS CHARACTER VIEW-AS EDITOR SIZE 60 BY 5.
      DEFINE VARIABLE ClipItem AS CHARACTER.
      
      /* Copy rows of integer items to the clipboard */
      /* and display the clipboard value.            */
      CLIPBOARD:MULTIPLE=TRUE.
      CLIPBOARD:ITEMS-PER-ROW=5.
      REPEAT i = 1 TO 20: 
         CLIPBOARD:VALUE=STRING(i).
      END.
      CLIPBOARD:MULTIPLE=FALSE.
      ClipBuffer = CLIPBOARD:VALUE.
      ENABLE ClipBuffer WITH FRAME A.
      DISPLAY SPACE(1) ClipBuffer LABEL "Clipboard Data" WITH FRAME A.
      PAUSE.  
    
      /* Display each item of the clipboard value. */
      CLIPBOARD:MULTIPLE=TRUE.
      ClipItem="".
      REPEAT WHILE ClipItem <> ?:
         ClipItem=CLIPBOARD:VALUE.
         IF ClipItem <> ? THEN
            DISPLAY SPACE(1) ClipItem 
               FORMAT "x(16)" LABEL "Clipboard Item" WITH DOWN FRAME B.
      END.
      CLIPBOARD:MULTIPLE=FALSE. 
    

NOTES

SEE ALSO

FOCUS System Handle


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095