GRIDPLUS2 - Clipboard/Clear Commands | ![]() |
||||||
|
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} }
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"} }