Remove zoom-on-ctrl-scroll and make quit-on-escape preventable

This commit is contained in:
Paul Rouget 2015-10-22 09:08:01 +02:00
parent ea000471d3
commit e60f02c3ba

View file

@ -170,7 +170,6 @@ impl Window {
(_, VirtualKeyCode::RAlt) => self.toggle_modifier(RIGHT_ALT),
(_, VirtualKeyCode::LWin) => self.toggle_modifier(LEFT_SUPER),
(_, VirtualKeyCode::RWin) => self.toggle_modifier(RIGHT_SUPER),
(ElementState::Pressed, VirtualKeyCode::Escape) => return true,
(_, key_code) => {
match Window::glutin_key_to_script_key(key_code) {
Ok(key) => {
@ -203,24 +202,11 @@ impl Window {
WindowEvent::MouseWindowMoveEventClass(Point2D::typed(x as f32, y as f32)));
}
Event::MouseWheel(delta) => {
if self.ctrl_pressed() {
// Ctrl-Scrollwheel simulates a "pinch zoom" gesture.
let dy = match delta {
MouseScrollDelta::LineDelta(_, dy) => dy,
MouseScrollDelta::PixelDelta(_, dy) => dy
};
if dy < 0.0 {
self.event_queue.borrow_mut().push(WindowEvent::PinchZoom(1.0 / 1.1));
} else if dy > 0.0 {
self.event_queue.borrow_mut().push(WindowEvent::PinchZoom(1.1));
}
} else {
match delta {
MouseScrollDelta::LineDelta(dx, dy) => {
self.scroll_window(dx, dy * LINE_HEIGHT);
}
MouseScrollDelta::PixelDelta(dx, dy) => self.scroll_window(dx, dy)
match delta {
MouseScrollDelta::LineDelta(dx, dy) => {
self.scroll_window(dx, dy * LINE_HEIGHT);
}
MouseScrollDelta::PixelDelta(dx, dy) => self.scroll_window(dx, dy)
}
},
Event::Refresh => {
@ -235,11 +221,6 @@ impl Window {
false
}
#[inline]
fn ctrl_pressed(&self) -> bool {
self.key_modifiers.get().intersects(LEFT_CONTROL | RIGHT_CONTROL)
}
fn toggle_modifier(&self, modifier: KeyModifiers) {
let mut modifiers = self.key_modifiers.get();
modifiers.toggle(modifier);
@ -672,6 +653,10 @@ impl WindowMethods for Window {
self.event_queue.borrow_mut().push(WindowEvent::Navigation(WindowNavigateMsg::Back));
}
(NONE, Key::Escape) => {
self.event_queue.borrow_mut().push(WindowEvent::Quit);
}
(CMD_OR_ALT, Key::Right) => {
self.event_queue.borrow_mut().push(WindowEvent::Navigation(WindowNavigateMsg::Forward));
}