Skip to content

Commit 0abce18

Browse files
committed
Change logic
1 parent 1f1653c commit 0abce18

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

masonry/src/widgets/button.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,15 @@ impl Widget for Button {
112112
event: &PointerEvent,
113113
) {
114114
match event {
115-
PointerEvent::Down {
116-
button: Some(PointerButton::Primary),
117-
..
118-
} => {
119-
ctx.capture_pointer();
120-
// Changes in pointer capture impact appearance, but not accessibility node
121-
ctx.request_paint_only();
122-
trace!("Button {:?} pressed", ctx.widget_id());
115+
PointerEvent::Down { button, .. } => {
116+
if *button == Some(PointerButton::Primary) {
117+
ctx.capture_pointer();
118+
// Changes in pointer capture impact appearance, but not accessibility node
119+
ctx.request_paint_only();
120+
trace!("Button {:?} pressed", ctx.widget_id());
121+
}
122+
// Any click event should lead to this widget getting focused.
123+
ctx.request_focus();
123124
}
124125
PointerEvent::Up {
125126
button: Some(PointerButton::Primary),
@@ -134,10 +135,6 @@ impl Widget for Button {
134135
// Changes in pointer capture impact appearance, but not accessibility node
135136
ctx.request_paint_only();
136137
}
137-
PointerEvent::Down { .. } => {
138-
// Any non-primary click event should lead to this widget getting focused.
139-
ctx.request_focus();
140-
}
141138
_ => (),
142139
}
143140
}

masonry/src/widgets/checkbox.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,15 @@ impl Widget for Checkbox {
113113
event: &PointerEvent,
114114
) {
115115
match event {
116-
PointerEvent::Down {
117-
button: Some(PointerButton::Primary),
118-
..
119-
} => {
120-
ctx.capture_pointer();
121-
trace!("Checkbox {:?} pressed", ctx.widget_id());
116+
PointerEvent::Down { button, .. } => {
117+
if *button == Some(PointerButton::Primary) {
118+
ctx.capture_pointer();
119+
// Checked state impacts appearance and accessibility node
120+
ctx.request_render();
121+
trace!("Checkbox {:?} pressed", ctx.widget_id());
122+
}
123+
// Any click event should lead to this widget getting focused.
124+
ctx.request_focus();
122125
}
123126
PointerEvent::Up {
124127
button: Some(PointerButton::Primary),
@@ -129,10 +132,6 @@ impl Widget for Checkbox {
129132
trace!("Checkbox {:?} released", ctx.widget_id());
130133
}
131134
}
132-
PointerEvent::Down { .. } => {
133-
// Any non-primary click event should lead to this widget getting focused.
134-
ctx.request_focus();
135-
}
136135
_ => (),
137136
}
138137
}

0 commit comments

Comments
 (0)