Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous message
slashupp is currently offline  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

 
Read Message
Read Message
Previous Topic: How to handle copy & paste with focus changing
Next Topic: [BUG] Patch to Switch.cpp to support touch screens
Goto Forum:
  


Current Time: Thu Sep 04 19:51:08 CEST 2025

Total time taken to generate the page: 0.05651 seconds