Previous Next

CLIPBOARD system handle
A handle to the system clipboard widget. The CLIPBOARD handle allows you to implement interactions that allow the user to transfer data between ABL field‑level widgets, or between ABL field‑level widgets and the widgets of other applications running on the system. ABL 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.
Attributes
 
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 OpenEdge Development: Programming Interfaces.
 
DEFINE VARIABLE lStat AS LOGICAL NO-UNDO.
. . .
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 ASSIGN
      CLIPBOARD:VALUE = FOCUS:SELECTION-TEXT
      lStat           = FOCUS:REPLACE-SELECTION-TEXT("").
    ELSE ASSIGN
      CLIPBOARD:VALUE    = FOCUS:SCREEN-VALUE
      FOCUS:SCREEN-VALUE = "".
  END.
  ELSE ASSIGN /* For FILL-IN */
    CLIPBOARD:VALUE    = FOCUS:SCREEN-VALUE
    FOCUS:SCREEN-VALUE = "".
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
      lStat = 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.
2.
3.
4.
 
DEFINE VARIABLE ClipBuffer AS CHARACTER NO-UNDO
  VIEW-AS EDITOR SIZE 60 BY 5.
DEFINE VARIABLE ClipItem   AS CHARACTER NO-UNDO.
DEFINE VARIABLE ix         AS INTEGER   NO-UNDO.
 
/* Copy rows of integer items to the clipboard, display the clipboard value. */
ASSIGN
  CLIPBOARD:MULTIPLE      = TRUE
  CLIPBOARD:ITEMS-PER-ROW = 5.
 
REPEAT ix = 1 TO 20: 
  CLIPBOARD:VALUE = STRING(ix).
END.
 
ASSIGN
  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. */
ASSIGN
  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 
*
*
*
*
PRO_TEXT — Specifies the standard text format on your system (CF_TEXT in Windows).
*
PRO_MULTIPLE — Specifies that the data in the clipboard contains tab or newline characters, and thus can be read as multiple items.
*
The ITEMS-PER-ROW attribute specifies how the AVM writes multiple items to the clipboard. Set the MULTIPLE attribute to TRUE before specifying ITEMS-PER-ROW. Then when you set ITEMS-PER-ROW to any integer value n greater than 1, the AVM terminates every nth value you assign to the VALUE attribute with a newline character and terminates all other values with a tab character. This formats the output in the clipboard into newline‑terminated rows of n items separated by tabs. The default value for the ITEMS-PER-ROW attribute is 1.
During a MULTIPLE write, you can set and reset ITEMS-PER-ROW at any time until you set the MULTIPLE attribute to FALSE. When you set the MULTIPLE attribute to FALSE, the AVM uses the current value of ITEMS-PER-ROW to format and flush the data to the clipboard, and resets the ITEMS-PER-ROW attribute to 1.
The value of ITEMS-PER-ROW has no effect when reading data from the clipboard.
*
When you set MULTIPLE to FALSE, the AVM treats all data in the clipboard as a single item. Thus, any character string you assign to the VALUE attribute replaces all data in the clipboard, and whenever you read the VALUE attribute it returns all the data in the clipboard.
When you set MULTIPLE to TRUE, the AVM treats the data in the clipboard as multiple items separated by tab or newline characters.
When you set the MULTIPLE attribute to TRUE and write values to the clipboard (assign values to the VALUE attribute), the AVM stores the values in a buffer until you set MULTIPLE to FALSE. At this time the AVM assigns the values to the clipboard separated from each other by tab or newline characters according to the value of the ITEMS-PER-ROW attribute. Note that the clipboard data itself does not change until you set MULTIPLE to FALSE. When you do set MULTIPLE to FALSE, all data previously in the clipboard is replaced by the items you have written.
When you set the MULTIPLE attribute to TRUE and read values from the clipboard (assign values from the VALUE attribute), each read returns the next item in the clipboard (starting with the first one). After all items have been read, the VALUE attribute returns the Unknown value (?). Setting the MULTIPLE attribute to FALSE and then to TRUE restarts the item pointer to read the first item of data in the clipboard.
Until you (or another application) write data to the clipboard, changing the value of the MULTIPLE attribute itself has no effect on clipboard contents. It only affects the way you can access the clipboard for reading and writing.
The default value for the MULTIPLE attribute is FALSE.
*
*
When the MULTIPLE attribute is FALSE, reading the VALUE attribute returns the current value in the clipboard as a single item. If there is no data in the clipboard, the VALUE attribute returns the Unknown value (?). Writing to the VALUE attribute immediately changes the current value in the clipboard to the value that is written.
When the MULTIPLE attribute is TRUE, reading the VALUE attribute either references one of the multiple data items in the clipboard, or references the Unknown value (?) if all items have been read or there is no data in the clipboard. Writing to the VALUE attribute buffers each assignment and replaces the current data in the clipboard with the multiple values assigned when the MULTIPLE attribute is set to FALSE. See the previous description of the MULTIPLE attribute for more information.
Note:
Assigning the Unknown value (?) to the VALUE attribute has no effect. To write a null item or clear the system clipboard when writing a single item, assign the null string ("") to the VALUE attribute.
*
*
*
*
*
*
CutCTRL+X and SHIFT+DEL
*
CopyCTRL+C and CTRL+INS
*
PasteCTRL+V and SHIFT+INS
*
*
See also 
FOCUS system handle

Previous Next
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates.