1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#include <stdlib.h>
#include <stdio.h>
#include "iup.h"
#include "iupkey.h"
static int copy_cb(Ihandle* ih)
{
Ihandle* text = IupGetDialogChild(ih, "text");
Ihandle* clipboard = IupClipboard();
IupSetAttribute(clipboard, "TEXT", IupGetAttribute(text, "VALUE"));
IupDestroy(clipboard);
return IUP_DEFAULT;
}
static int paste_cb(Ihandle* ih)
{
Ihandle* text = IupGetDialogChild(ih, "text");
Ihandle* clipboard = IupClipboard();
IupSetAttribute(text, "VALUE", IupGetAttribute(clipboard, "TEXT"));
IupDestroy(clipboard);
return IUP_DEFAULT;
}
void ClipboardTest(void)
{
Ihandle *dlg = IupDialog(IupVbox(
IupSetAttributes(IupText(NULL), "SIZE=80x60, MULTILINE=YES, NAME=text, EXPAND=YES"),
IupSetCallbacks(IupButton("Copy", NULL), "ACTION", copy_cb, NULL),
IupSetCallbacks(IupButton("Paste", NULL), "ACTION", paste_cb, NULL),
NULL));
IupSetAttribute(dlg, "GAP", "10");
IupSetAttribute(dlg, "MARGIN", "20x20");
IupSetAttribute(dlg, "TITLE", "Clipboard Test");
IupShow(dlg);
}
#ifndef BIG_TEST
int main(int argc, char* argv[])
{
IupOpen(&argc, &argv);
ClipboardTest();
IupMainLoop();
IupClose();
return EXIT_SUCCESS;
}
#endif
|