Home » U++ TheIDE » U++ TheIDE: CodeEditor, Assist++, Topic++ » [Feature+Patch] CodeEditor: On mouse middle button click, paste selected or copied text.
[Feature+Patch] CodeEditor: On mouse middle button click, paste selected or copied text. [message #52910] |
Sat, 11 January 2020 17:48 |
omari
Messages: 276 Registered: March 2010
|
Experienced Member |
|
|
CodeEditor.h
virtual void MouseLeave();
virtual void MouseWheel(Point p, int zdelta, dword keyFlags);
+ virtual void MiddleDown(Point p, dword keyflags);
CodeEditor.cpp
void Upp::CodeEditor::MiddleDown(Point p, dword keyflags)
{
auto ShowTip = [this](Point p, String txt)
{
static ToolTip tip;
if(tip.IsOpen())
tip.Close();
tip.Set(txt);
tip.PopUp(this, p + GetVisibleScreenView().TopLeft(), true);
SetTimeCallback(700, [&]{GuiLock _;tip.Close();});
};
int64 l, h;
if(GetSelection(l, h)) {
int pos = GetMousePos32(p);
Insert(pos, GetSelectionW());
if(pos <= l){
int d = h - l;
l = h;
h += d;
}
else if(pos < h){
h += h - l;
}
SetSelection(l, h);
Refresh();
ShowTip(p, ". Inserting Selected text ");
}
else {
WString s = ReadClipboardUnicodeText();
if(s.GetCount()) {
int pos = GetMousePos32(p);
Insert(pos, s);
Refresh();
ShowTip(p, ". Inserting Clipboard text ");
}
}
}
regards
omari.
|
|
|
Goto Forum:
Current Time: Mon Apr 28 14:23:27 CEST 2025
Total time taken to generate the page: 0.00709 seconds
|