Replies: 3 comments
-
If the mouse is moving with the Button1Pressed then the ReportMousePosition must exxist in the mouse event event. Any grabbed view can now give up the grab to another view or maintaining still grabbed by using the events OnMouseGrab/OnMouseUngrab. If a view is doing that for moving a object from one place to another and want to finished the job, other view that can grab the mouse will try to get it, if the current grabbed view want or not. It may have priority over the others. |
Beta Was this translation helpful? Give feedback.
-
To illustrate what I think is wrong with the current Terminal.Gui (and v1) API in this regard, consider this class. public class MouseDemo : View
{
public MouseDemo ()
{
CanFocus = true;
MouseEvent += (s, e) =>
{
if (e.MouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed))
{
ColorScheme = Colors.ColorSchemes ["Toplevel"];
}
if (e.MouseEvent.Flags.HasFlag (MouseFlags.Button1Released))
{
ColorScheme = Colors.ColorSchemes ["Dialog"];
}
};
MouseLeave += (s, e) => { ColorScheme = Colors.ColorSchemes ["Dialog"]; };
}
} I want this view to show the "TopLevel" colorscheme while button1 is pressed; when button1 is released, or the mouse leaves the view, the color should go back to "Dialog". Here's how it behaves now. Note that if I press button1 outside of the view and drag into the view, the color changes to "Toplevel". This is not what I want. The current API provides me no way of knowing that the Now, I can work around this like this, but this is awful. public class MouseDemo : View
{
private bool _button1PressedOnEnter = false;
public MouseDemo ()
{
CanFocus = true;
MouseEvent += (s, e) =>
{
if (e.MouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed))
{
if (!_button1PressedOnEnter)
{
ColorScheme = Colors.ColorSchemes ["Toplevel"];
}
}
if (e.MouseEvent.Flags.HasFlag (MouseFlags.Button1Released))
{
ColorScheme = Colors.ColorSchemes ["Dialog"];
_button1PressedOnEnter = false;
}
};
MouseLeave += (s, e) =>
{
ColorScheme = Colors.ColorSchemes ["Dialog"];
_button1PressedOnEnter = false;
};
MouseEnter += (s, e) =>
{
_button1PressedOnEnter = e.MouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed);
};
}
} I think there should be a |
Beta Was this translation helpful? Give feedback.
-
FWIW, the impact of this behavior can be seen (in v1 and v2) in the Press button1 while in the Bounds of |
Beta Was this translation helpful? Give feedback.
-
If the mouse button is pressed. and the View under the mouse doesn't grab the mouse, and then the user moves the mouse over another view, that view gets a mouse event with
MouseFlags.Button1Pressed
. As far as i can tell, with the current API there's no way to tell that the mouse button was presssed before the mouse moved over the new view.Am I missing something?
Beta Was this translation helpful? Give feedback.
All reactions