mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-03 15:21:17 -05:00
A press Escape cancelled still sends the tool its release when the button goes up, as production's canvas sent it: a selection tool Cmd lent goes back to the tool it was lent from on that release
This commit is contained in:
@@ -115,6 +115,7 @@ impl VectorcraftApp {
|
||||
grab: None,
|
||||
carry_target: None,
|
||||
last_drag: None,
|
||||
escaped_press: false,
|
||||
panes: Default::default(),
|
||||
windows: crate::doc_windows::Windows::new(known),
|
||||
images_with_other_art: None,
|
||||
|
||||
@@ -96,6 +96,9 @@ pub struct CanvasCache {
|
||||
/// The last drag the tool was sent and the screen point it was at: when the view scrolls under the held
|
||||
/// pointer, the drag goes on at that point in the scrolled view.
|
||||
pub last_drag: Option<(egui::Pos2, vectorcraft_tools::PointerEvent)>,
|
||||
/// Escape cancelled the tool's press while the button is still down: its release still sends the tool its Up,
|
||||
/// which gives back a selection tool Cmd lent.
|
||||
pub escaped_press: bool,
|
||||
/// Window › Arrange › Tile: the renders the panes of the other documents draw.
|
||||
pub panes: canvas::Panes,
|
||||
/// Window › Arrange › Float in Window: what the floating document windows keep between frames.
|
||||
|
||||
@@ -361,6 +361,7 @@ impl CanvasTool for SessionTool<'_> {
|
||||
let (left, right, c) =
|
||||
(claim(&mut app, EngineKey::BracketLeft), claim(&mut app, EngineKey::BracketRight), claim(&mut app, EngineKey::Letter('c')));
|
||||
// shortcut: the sets are the combinations the tools have; a tool with another mix needs its own slice.
|
||||
app.canvas.escaped_press = true;
|
||||
let keys = match (left, right, curly, c) {
|
||||
(true, true, true, _) => BRACKETS_CURLY,
|
||||
(true, true, false, true) => BRACKETS_C,
|
||||
@@ -539,6 +540,15 @@ pub(crate) fn run(app: &mut VectorcraftApp, ui: &mut Ui, pass: &ToolPass) -> Too
|
||||
// The press phase says whether the canvas has the pointer: a dialog, floating panel or menu over it hides the
|
||||
// document point, and a drag that began on the canvas keeps its own phase over them.
|
||||
app.hover_doc = match (pass.press.phase, view) {
|
||||
// The framework ends a press at Escape; the engine's tool still takes the release that ends it.
|
||||
if app.canvas.escaped_press && !ui.input(|i| i.pointer.primary_down()) {
|
||||
app.canvas.escaped_press = false;
|
||||
dispatch(
|
||||
app,
|
||||
&PointerEvent { kind: PointerKind::Up, pos: Point::ZERO, mods: Mods::default(), backquote: false, pressure: 1.0, pen: None },
|
||||
view_info,
|
||||
);
|
||||
}
|
||||
(PressPhase::Idle, _) | (_, None) => None,
|
||||
(_, Some(view)) => ui.input(|i| i.pointer.hover_pos()).map(|p| view.to_doc(p)),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user