allow check box to be switched only by left mouse button
@@ -7,7 +7,7 @@ use crate::{
message::{MessageDirection, UiMessage},
vector_image::{Primitive, VectorImageBuilder},
widget::{Widget, WidgetBuilder, WidgetMessage},
- BuildContext, Control, HorizontalAlignment, NodeHandleMapping, Thickness, UiNode,
+ BuildContext, Control, HorizontalAlignment, MouseButton, NodeHandleMapping, Thickness, UiNode,
UserInterface, VerticalAlignment, BRUSH_BRIGHT, BRUSH_DARK, BRUSH_LIGHT, BRUSH_TEXT,
};
use fyrox_core::algebra::Vector2;
@@ -56,16 +56,18 @@ impl Control for CheckBox {
if let Some(msg) = message.data::<WidgetMessage>() {
match msg {
- WidgetMessage::MouseDown { .. } => {
- if message.destination() == self.handle()
- || self.widget.has_descendant(message.destination(), ui)
+ WidgetMessage::MouseDown { button, .. } => {
+ if *button == MouseButton::Left
+ && (message.destination() == self.handle()
+ || self.widget.has_descendant(message.destination(), ui))
{
ui.capture_mouse(self.handle());
}
}
- WidgetMessage::MouseUp { .. } => {
- if message.destination() == self.handle()
- || self.widget.has_descendant(message.destination(), ui)
+ WidgetMessage::MouseUp { button, .. } => {
+ if *button == MouseButton::Left
+ && (message.destination() == self.handle()
+ || self.widget.has_descendant(message.destination(), ui))
{
ui.release_mouse_capture();
