Home » U++ Library support » U++ Widgets - General questions or Mixed problems » X11 middle mouse copy paste in own widget [SOLVED]
|
Re: X11 middle mouse in own widget [message #48594 is a reply to message #48593] |
Fri, 04 August 2017 10:54 |
slashupp
Messages: 231 Registered: July 2009
|
Experienced Member |
|
|
Like most everything in Upp this turned out to be very simple & easy:
run the code below, double-click in the box and middle-click in some other editor to copy the text to that editor
then select==hilite some text somewhere and middle-click in the box to paste that text
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
#define LAYOUTFILE <test_x11_midclick_cnp/test_x11_midclick_cnp.lay>
#include <CtrlCore/lay.h>
struct Box : public Ctrl
{
typedef Box CLASSNAME;
String text;
Box()
{
AddFrame(ThinInsetFrame());
text="something";
}
virtual ~Box() {}
virtual void Paint(Draw &drw)
{
drw.DrawText(10,10, text);
}
virtual String GetSelectionData(const String &fmt) const
{
return text;
}
virtual void LeftDouble(Point p, dword kf)
{
SetSelectionSource(ClipFmtsText());
}
virtual void MiddleDown(Point p, dword kf)
{
if(AcceptText(Selection()))
{
text=GetString(Selection());
Refresh();
}
}
};
struct test_x11_midclick_cnp : public TopWindow
{
typedef test_x11_midclick_cnp CLASSNAME;
//EditString eb;
Box box;
test_x11_midclick_cnp();
};
test_x11_midclick_cnp::test_x11_midclick_cnp()
{
Title("test_x11_midclick_cnp");
SetRect(0,0,300,300);
Sizeable();
CenterScreen();
//Add(eb.LeftPosZ(10, 200).TopPosZ(10, 20));
Add(box.LeftPos(10,200).TopPos(40,200));
}
GUI_APP_MAIN
{
test_x11_midclick_cnp().Run();
}
I was looking for complexity where there was none!
Thx mirek
|
|
|
Goto Forum:
Current Time: Fri Apr 26 10:48:35 CEST 2024
Total time taken to generate the page: 0.03889 seconds
|