Skip to content

Commit

Permalink
added pointer mmove on grab
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratik Agrawal authored and Pratik Agrawal committed Jan 4, 2025
1 parent 60d08f0 commit 9b08a4b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions editor/src/messages/input_mapper/input_mappings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,13 @@ pub fn input_mappings() -> Mapping {
//
// NavigationMessage
entry!(KeyDown(MouseMiddle); modifiers=[Alt], action_dispatch=NavigationMessage::BeginCanvasTilt { was_dispatched_from_menu: false }),
// entry!(KeyDown(Space); modifiers=[MouseLeft],action_dispatch=NavigationMessage::BeginCanvasPan),
entry!(KeyDown(Command); action_dispatch=NavigationMessage::SetCursorState { is_active: true }),
entry!(PointerMove; modifiers=[Command], action_dispatch=NavigationMessage::SetCursorState { is_active: true }),
entry!(KeyUp(Command); action_dispatch=NavigationMessage::SetCursorState { is_active: false }),
entry!(KeyDown(MouseMiddle); modifiers=[Shift], action_dispatch=NavigationMessage::BeginCanvasZoom),
entry!(KeyDown(MouseLeft); modifiers=[Shift, Space], action_dispatch=NavigationMessage::BeginCanvasZoom),
entry!(KeyDown(MouseMiddle); action_dispatch=NavigationMessage::BeginCanvasPan),
entry!(KeyDown(MouseLeft); modifiers=[Space], action_dispatch=NavigationMessage::BeginCanvasPan),
entry!(KeyDown(MouseLeft); modifiers=[Command], action_dispatch=NavigationMessage::BeginCanvasPan),
entry!(KeyDown(NumpadAdd); modifiers=[Accel], action_dispatch=NavigationMessage::CanvasZoomIncrease { center_on_mouse: false }),
entry!(KeyDown(Equal); modifiers=[Accel], action_dispatch=NavigationMessage::CanvasZoomIncrease { center_on_mouse: false }),
entry!(KeyDown(Minus); modifiers=[Accel], action_dispatch=NavigationMessage::CanvasZoomDecrease { center_on_mouse: false }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,6 @@ impl fmt::Display for Key {
}
}

pub fn is_key_held(key: Key, keyboard_state: &KeyStates) -> bool {
let key_index = key as usize;
keyboard_state.get(key_index)
}

impl From<Key> for LayoutKey {
fn from(key: Key) -> Self {
Self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl MessageHandler<NavigationMessage, NavigationMessageData<'_>> for Navigation
self.navigation_operation = NavigationOperation::Pan { pan_original_for_abort: ptz.pan };
}
NavigationMessage::SetCursorState { is_active } => {
// info!("SetCursorState called with is_active: {}", is_active);
if is_active {
responses.add(FrontendMessage::UpdateMouseCursor { cursor: MouseCursorIcon::Grab });
} else {
Expand Down
13 changes: 11 additions & 2 deletions frontend/src/io-managers/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ export function createInputManager(editor: Editor, dialog: DialogState, portfoli

async function onKeyDown(e: KeyboardEvent) {
const key = await getLocalizedScanCode(e);

console.log("Key pressed:", key);

Check warning on line 105 in frontend/src/io-managers/input.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
if(key=="Space"){

Check failure on line 106 in frontend/src/io-managers/input.ts

View workflow job for this annotation

GitHub Actions / build

Replace `(key=="Space")` with `·(key·==·"Space")·`
e.preventDefault();
// e.stopPropagation();
console.log("Space key detected and preventDefault applied.");

Check warning on line 109 in frontend/src/io-managers/input.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
}
const NO_KEY_REPEAT_MODIFIER_KEYS = ["ControlLeft", "ControlRight", "ShiftLeft", "ShiftRight", "MetaLeft", "MetaRight", "AltLeft", "AltRight", "AltGraph", "CapsLock", "Fn", "FnLock"];
if (e.repeat && NO_KEY_REPEAT_MODIFIER_KEYS.includes(key)) return;

Expand All @@ -120,7 +125,11 @@ export function createInputManager(editor: Editor, dialog: DialogState, portfoli

async function onKeyUp(e: KeyboardEvent) {
const key = await getLocalizedScanCode(e);

// if(key=="Space"){
// e.preventDefault();
// e.stopPropagation();

Check failure on line 130 in frontend/src/io-managers/input.ts

View workflow job for this annotation

GitHub Actions / build

Delete `↹`
// console.log("Space key detected and preventDefault applied.");
// }
if (await shouldRedirectKeyboardEventToBackend(e)) {
e.preventDefault();
const modifiers = makeKeyboardModifiersBitfield(e);
Expand Down

0 comments on commit 9b08a4b

Please sign in to comment.