Added modifiers to scroll wheel eevent

This commit is contained in:
Mikayla Maki 2022-08-19 12:10:12 -07:00
parent a806634b82
commit efd3247ce4
7 changed files with 16 additions and 1 deletions

View file

@ -1582,6 +1582,7 @@ impl Element for EditorElement {
position, position,
delta, delta,
precise, precise,
..
}) => self.scroll(*position, *delta, *precise, layout, paint, cx), }) => self.scroll(*position, *delta, *precise, layout, paint, cx),
&Event::ModifiersChanged(event) => self.modifiers_changed(event, cx), &Event::ModifiersChanged(event) => self.modifiers_changed(event, cx),

View file

@ -293,6 +293,7 @@ impl Element for Flex {
position, position,
delta, delta,
precise, precise,
..
}) = event }) = event
{ {
if *remaining_space < 0. && bounds.contains_point(position) { if *remaining_space < 0. && bounds.contains_point(position) {

View file

@ -316,6 +316,7 @@ impl Element for List {
position, position,
delta, delta,
precise, precise,
..
}) = event }) = event
{ {
if bounds.contains_point(*position) if bounds.contains_point(*position)

View file

@ -315,6 +315,7 @@ impl Element for UniformList {
position, position,
delta, delta,
precise, precise,
..
}) = event }) = event
{ {
if bounds.contains_point(*position) if bounds.contains_point(*position)

View file

@ -24,6 +24,10 @@ pub struct ScrollWheelEvent {
pub position: Vector2F, pub position: Vector2F,
pub delta: Vector2F, pub delta: Vector2F,
pub precise: bool, pub precise: bool,
pub ctrl: bool,
pub alt: bool,
pub shift: bool,
pub cmd: bool,
} }
#[derive(Hash, PartialEq, Eq, Copy, Clone, Debug)] #[derive(Hash, PartialEq, Eq, Copy, Clone, Debug)]

View file

@ -148,6 +148,8 @@ impl Event {
}) })
} }
NSEventType::NSScrollWheel => window_height.map(|window_height| { NSEventType::NSScrollWheel => window_height.map(|window_height| {
let modifiers = native_event.modifierFlags();
Self::ScrollWheel(ScrollWheelEvent { Self::ScrollWheel(ScrollWheelEvent {
position: vec2f( position: vec2f(
native_event.locationInWindow().x as f32, native_event.locationInWindow().x as f32,
@ -158,6 +160,10 @@ impl Event {
native_event.scrollingDeltaY() as f32, native_event.scrollingDeltaY() as f32,
), ),
precise: native_event.hasPreciseScrollingDeltas() == YES, precise: native_event.hasPreciseScrollingDeltas() == YES,
ctrl: modifiers.contains(NSEventModifierFlags::NSControlKeyMask),
alt: modifiers.contains(NSEventModifierFlags::NSAlternateKeyMask),
shift: modifiers.contains(NSEventModifierFlags::NSShiftKeyMask),
cmd: modifiers.contains(NSEventModifierFlags::NSCommandKeyMask),
}) })
}), }),
NSEventType::NSLeftMouseDragged NSEventType::NSLeftMouseDragged

View file

@ -703,7 +703,7 @@ impl Terminal {
///Scroll the terminal ///Scroll the terminal
pub fn scroll(&mut self, scroll: &ScrollWheelEvent, origin: Vector2F) { pub fn scroll(&mut self, scroll: &ScrollWheelEvent, origin: Vector2F) {
if self.mouse_mode(false) { if self.mouse_mode(scroll.shift) {
//TODO: Currently this only sends the current scroll reports as they come in. Alacritty //TODO: Currently this only sends the current scroll reports as they come in. Alacritty
//Sends the *entire* scroll delta on *every* scroll event, only resetting it when //Sends the *entire* scroll delta on *every* scroll event, only resetting it when
//The scroll enters 'TouchPhase::Started'. Do I need to replicate this? //The scroll enters 'TouchPhase::Started'. Do I need to replicate this?
@ -720,6 +720,7 @@ impl Terminal {
} else if self } else if self
.last_mode .last_mode
.contains(TermMode::ALT_SCREEN | TermMode::ALTERNATE_SCROLL) .contains(TermMode::ALT_SCREEN | TermMode::ALTERNATE_SCROLL)
&& !scroll.shift
{ {
//TODO: See above TODO, also applies here. //TODO: See above TODO, also applies here.
let scroll_lines = ((scroll.delta.y() * ALACRITTY_SCROLL_MULTIPLIER) let scroll_lines = ((scroll.delta.y() * ALACRITTY_SCROLL_MULTIPLIER)