Hot and cold MouseEvents?
See original GitHub issueIs my understanding correct in that there is not currently a cold-key like behaviour for mouse events? I see here that it’s apparently been considered but not yet implemented for having them being bubbled up if the mouse event is not handled (returns false): https://github.com/migueldeicaza/gui.cs/blob/52a5fccdc412367405790dd811ebf5410c1c9a39/Terminal.Gui/Core/Application.cs#L591
If so, you might ask why I want such a thing, so here I’ll try to explain:
class TerminalTextView : TextView
{
// ProcessHotMouseEvent does not yet exist, but to express the idea:
public override bool ProcessHotMouseEvent(MouseEvent mouseEvent)
{
// right click
if(mouseEvent.Flags == MouseFlags.Button3Pressed)
{
if (HasFocus && Selecting)
{
Copy();
Selecting = false;
}
else
{
return false; // handle paste in InputTerminalTextView coldkey
}
}
return base.OnMouseEvent(mouseEvent);
}
}
class InputTerminalTextView: TerminalTextView
{
// ProcessColdMouseEvent does not yet exist, but to express the idea:
public override bool ProcessColdMouseEvent(MouseEvent mouseEvent)
{
// right click
if(mouseEvent.Flags == MouseFlags.Button3Pressed)
{
SetFocus();
Paste();
return true;
}
return base.ProcessColdMouseEvent(mouseEvent);
}
}
So what I’d be trying to accomplish here is right click copy + paste (like in a terminal).
The user would be able to select text in another (readonly) textview, right click anywhere to copy selected (assuming ProcessHotMouseEvent
would occur before changing View’s focus), and then right clicking again (i.e. without anything selected) would paste it into the InputTerminalTextView.
This is probably quite a niche use-case so it might not be worth a change to core repo. FWIW I’m not entirely sure if this idea requires such functionality and maybe there’s another way of doing it, it’s just the first to come to mind since I’m already doing a similar thing with the hotkey/coldkeys. But I thought I’d mention the idea since I noticed that little note in the code, so maybe it’s sort of considerable? IDK, please correct me if I’m off here - and please if any suggestions on a alternative solution to getting this idea working would be greatly appreciated.
PS: Just want to thank again for all of the time and effort in making this project, I really appreciate it, and all the fantastic help I’ve received getting started on my idea. 😃
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top GitHub Comments
Thanks! This is just what I needed, here is a code sample displaying use:
Seems to work perfect for what I want. 😃
Ah, sorry to both. So, in that case the
Application.RootMouseEvent
will be suffice, I think.