GRIDPLUS2 - Clipboard/Clear Commands
Home Reference Manpage Examples Download License Contact

Clipboard/Clear Commands

GRIDPLUS provides four commands which can be used to control clipboard operations and clear selected text for entry/text widgets (See Example 7).

gpclear ?item?Clears (Deletes) selected text.
gpcopy ?item?Copies selected text to clipboard.
gpcut ?item?Cuts selected text to clipboard.
gppaste ?item?Copies text from clipboard.

The item parameter is optional. If not specified the command is applied to the widget which has focus.

Note: For gpcopy, gpcut and gppaste the item parameter (if used) must identify a text widget. For entry widgets only the "widget with focus" option is supported.

Example

Window:

Source Code:

gridplus entry .entry1 -space 0 -title "Entry 1" {
   {.field 40} {}
}

gridplus entry .entry2 -space 0 -title "Entry 2" {
   {.field 40} {}
}

gridplus text .text1 -title "Text 1"

gridplus text .text2 -title "Text 2"

gridplus button .focus-button -takefocus 0 -title "Focus" {
   {"Cut" .cut ~gpcut} {"Copy" .copy ~gpcopy} {"Paste" .paste ~gppaste} {"Clear" .clear ~gpclear}
}

gridplus button .text1-button -takefocus 0 -title "Text 1" {
   {"Cut" .cut "~gpcut .text1"} {"Copy" .copy "~gpcopy .text1"} {"Paste" .paste "~gppaste .text1"} {"Clear" .clear "~gpclear .text1"}
}

gridplus button .text2-button -takefocus 0 -title "Text 2" {
   {"Cut" .cut "~gpcut .text2"} {"Copy" .copy "~gpcopy .text2"} {"Paste" .paste "~gppaste .text2"} {"Clear" .clear "~gpclear .text2"}
}

gridplus layout .main -wtitle "Example" {
   .entry1:ew
   .entry2:ew
   .text1:ew
   .text2:ew
   .focus-button:ew
   .text1-button:ew
   .text2-button:ew
}

pack .main

gpset .entry1,field "This is entry widget one"
gpset .entry2,field "This is entry widget two"
gpset .text1        "This is text widget one"
gpset .text2        "This is text widget two"

Comments:

gridplus button .focus-button -takefocus 0 -title "Focus" {
   {"Cut" .cut ~gpcut} {"Copy" .copy ~gpcopy} {"Paste" .paste ~gppaste} {"Clear" .clear ~gpclear}
}

Creates a button grid called ".focus-button" which contains four buttons ("Cut", "Copy", "Paste" and "Clear"). The buttons invoke the GRIDPLUS "gpcut", "gpcopy", "gppaste" and "gpclear" commands respectively. The item parameter is not specified for the commands. In this case the operation will apply to the entry/text widget which currently has focus.
gridplus button .text1-button -takefocus 0 -title "Text 1" {
   {"Cut" .cut "~gpcut .text1"} {"Copy" .copy "~gpcopy .text1"} {"Paste" .paste "~gppaste .text1"} {"Clear" .clear "~gpclear .text1"}
}

Creates a button grid called ".text1-button" which contains four buttons ("Cut", "Copy", "Paste" and "Clear"). The buttons invoke the GRIDPLUS "gpcut", "gpcopy", "gppaste" and "gpclear" commands respectively. The item parameter is set to ".text1" for all of the commands. In this case the operations will apply to the ".text1" text widget.
gridplus button .text2-button -takefocus 0 -title "Text 2" {
   {"Cut" .cut "~gpcut .text2"} {"Copy" .copy "~gpcopy .text2"} {"Paste" .paste "~gppaste .text2"} {"Clear" .clear "~gpclear .text2"}
}

Creates a button grid called ".text2-button" which contains four buttons ("Cut", "Copy", "Paste" and "Clear"). The buttons invoke the GRIDPLUS "gpcut", "gpcopy", "gppaste" and "gpclear" commands respectively. The item parameter is set to ".text2" for all of the commands. In this case the operations will apply to the ".text2" text widget.

Copyright © 2008 Adrian Davis.