From 32e8447daa6add927249486f65673b6bdee33e2c Mon Sep 17 00:00:00 2001 From: Oren Kedem Date: Wed, 16 Jun 2021 11:36:20 +0300 Subject: [PATCH 1/5] Fix mac infinite scroll bug when using standard mouse --- Launch-Scripts/create-shortcut.js | 40 +------------------ .../Spaces/Charting-Space/Scales/RateScale.js | 2 +- .../Charting-Space/Scales/TimeFrameScale.js | 2 +- .../Spaces/Charting-Space/Scales/TimeScale.js | 2 +- .../UI/Spaces/Charting-Space/Viewport.js | 2 +- .../UI/Spaces/Floating-Space/Picker.js | 2 +- .../UI/Spaces/Panel-Space/LayersPanel.js | 2 +- .../UI/Spaces/Side-Space/ListView.js | 2 +- UI/Globals.js | 1 + uninstall.js | 18 +-------- 10 files changed, 11 insertions(+), 62 deletions(-) diff --git a/Launch-Scripts/create-shortcut.js b/Launch-Scripts/create-shortcut.js index c306503fe..bc28e66fb 100644 --- a/Launch-Scripts/create-shortcut.js +++ b/Launch-Scripts/create-shortcut.js @@ -92,45 +92,7 @@ if (os.platform() == "win32") { // Mac Shortcuts } else if (os.platform() == "darwin") { - const icon = path.join( __dirname,"/superalgos.ico"); - const createShortcutCommand = `chmod +x ${name}.command & cp ${name}.command ~/Desktop/${name}.command` - const installFileIconcommand = `npm install fileicon`; - const changeIconCommand = `./node_modules/fileicon/bin/fileicon set ~/Desktop/${name}.command ./Launch-Scripts/superalgos.ico` - const unInstallFileIconcommand = `npm uninstall fileicon`; - - try { - // Create .desktop shortcut file - fs.writeFileSync( `${name}.command`, - `#!/bin/sh - cd ${__dirname} - cd .. - node run - "$SHELL"`, - ); - - // Place shortcut in proper folders - execSync( createShortcutCommand,{ timeout: 30000}) - - // Remove temporary .command file - fs.unlinkSync( `${name}.command` ) - - //Install fileicon utility - execSync(installFileIconcommand, {stdio: 'inherit', timeout: 30000}); - - //change Icon - execSync(changeIconCommand, {stdio: 'inherit', timeout: 30000}); - - //Un-Install fileicon utility - execSync(unInstallFileIconcommand, {stdio: 'inherit', timeout: 30000}); - } catch (error) { - console.log(''); - console.log("There was an error installing a shortcut: "); - console.log(''); - console.log( error ); - return; - } - - console.log("Shortcuts added successfully!"); + console.log( "Automatic shortcut creation is not yet supported on Mac. If you would like to see this feature add, message @harrellbm on telegram or discord to ask how you can help!") // Misc Operating System } else { diff --git a/Projects/Foundations/UI/Spaces/Charting-Space/Scales/RateScale.js b/Projects/Foundations/UI/Spaces/Charting-Space/Scales/RateScale.js index 82506f523..8b4e24e67 100644 --- a/Projects/Foundations/UI/Spaces/Charting-Space/Scales/RateScale.js +++ b/Projects/Foundations/UI/Spaces/Charting-Space/Scales/RateScale.js @@ -175,7 +175,7 @@ function newRateScale() { } function onMouseWheel(event, autoScale) { - if (IS_MAC) { + if (IS_MAC && Math.abs(event.wheelDelta) < MAC_MOUSE_WHEEL_INFINITE_SCROLL_THRESHOLD) { let sensitivity if (event.delta < 0) { if (event.shiftKey === true) { diff --git a/Projects/Foundations/UI/Spaces/Charting-Space/Scales/TimeFrameScale.js b/Projects/Foundations/UI/Spaces/Charting-Space/Scales/TimeFrameScale.js index cd21865b7..6c02305e0 100644 --- a/Projects/Foundations/UI/Spaces/Charting-Space/Scales/TimeFrameScale.js +++ b/Projects/Foundations/UI/Spaces/Charting-Space/Scales/TimeFrameScale.js @@ -251,7 +251,7 @@ function newTimeFrameScale() { } function onMouseWheel(event) { - if (IS_MAC) { + if (IS_MAC && Math.abs(event.wheelDelta) < MAC_MOUSE_WHEEL_INFINITE_SCROLL_THRESHOLD) { let sensitivity if (event.delta < 0) { if (event.shiftKey === true) { diff --git a/Projects/Foundations/UI/Spaces/Charting-Space/Scales/TimeScale.js b/Projects/Foundations/UI/Spaces/Charting-Space/Scales/TimeScale.js index 790e54a0e..cb13e8b21 100644 --- a/Projects/Foundations/UI/Spaces/Charting-Space/Scales/TimeScale.js +++ b/Projects/Foundations/UI/Spaces/Charting-Space/Scales/TimeScale.js @@ -126,7 +126,7 @@ function newTimeScale() { } function onMouseWheel(event, autoScale) { - if (IS_MAC) { + if (IS_MAC && Math.abs(event.wheelDelta) < MAC_MOUSE_WHEEL_INFINITE_SCROLL_THRESHOLD) { let sensitivity if (event.delta < 0) { if (event.shiftKey === true) { diff --git a/Projects/Foundations/UI/Spaces/Charting-Space/Viewport.js b/Projects/Foundations/UI/Spaces/Charting-Space/Viewport.js index 9942ab03b..dda7207f8 100644 --- a/Projects/Foundations/UI/Spaces/Charting-Space/Viewport.js +++ b/Projects/Foundations/UI/Spaces/Charting-Space/Viewport.js @@ -206,7 +206,7 @@ function newViewport() { if ((event.ctrlKey === true || event.metaKey === true)) { return } let morePower = 1 - if (IS_MAC) { + if (IS_MAC && Math.abs(event.wheelDelta) < MAC_MOUSE_WHEEL_INFINITE_SCROLL_THRESHOLD) { let sensitivity if (event.delta < 0) { if (event.shiftKey === true) { diff --git a/Projects/Foundations/UI/Spaces/Floating-Space/Picker.js b/Projects/Foundations/UI/Spaces/Floating-Space/Picker.js index cf8649970..38808f107 100644 --- a/Projects/Foundations/UI/Spaces/Floating-Space/Picker.js +++ b/Projects/Foundations/UI/Spaces/Floating-Space/Picker.js @@ -138,7 +138,7 @@ function newPicker() { function onMouseWheel() { - if (IS_MAC) { + if (IS_MAC && Math.abs(event.wheelDelta) < MAC_MOUSE_WHEEL_INFINITE_SCROLL_THRESHOLD) { let sensitivity if (event.delta < 0) { if (event.shiftKey === true) { diff --git a/Projects/Foundations/UI/Spaces/Panel-Space/LayersPanel.js b/Projects/Foundations/UI/Spaces/Panel-Space/LayersPanel.js index 1eb9b2b7f..f7500182d 100644 --- a/Projects/Foundations/UI/Spaces/Panel-Space/LayersPanel.js +++ b/Projects/Foundations/UI/Spaces/Panel-Space/LayersPanel.js @@ -212,7 +212,7 @@ function newLayersPanel() { function onMouseWheel(event) { - if (IS_MAC) { + if (IS_MAC && Math.abs(event.wheelDelta) < MAC_MOUSE_WHEEL_INFINITE_SCROLL_THRESHOLD) { let sensitivity if (event.delta < 0) { if (event.shiftKey === true) { diff --git a/Projects/Foundations/UI/Spaces/Side-Space/ListView.js b/Projects/Foundations/UI/Spaces/Side-Space/ListView.js index 4d13453aa..c1dde08b5 100644 --- a/Projects/Foundations/UI/Spaces/Side-Space/ListView.js +++ b/Projects/Foundations/UI/Spaces/Side-Space/ListView.js @@ -124,7 +124,7 @@ function newListView() { function onMouseWheel(event) { - if (IS_MAC) { + if (IS_MAC && Math.abs(event.wheelDelta) < MAC_MOUSE_WHEEL_INFINITE_SCROLL_THRESHOLD) { let sensitivity if (event.delta < 0) { if (event.shiftKey === true) { diff --git a/UI/Globals.js b/UI/Globals.js index 53f2b0e8f..b3588616d 100644 --- a/UI/Globals.js +++ b/UI/Globals.js @@ -69,6 +69,7 @@ const MAC_AMOUNT_FACTOR = 5 const IS_MAC = navigator.platform.toUpperCase().indexOf('MAC') >= 0 const MAC_ZOOM_SENSITIVITY = 5 const MAC_SCROLL_SENSITIVITY = 20 +const MAC_MOUSE_WHEEL_INFINITE_SCROLL_THRESHOLD= 120 const DEBUG = {} diff --git a/uninstall.js b/uninstall.js index be6ba5d57..0203d7e5d 100644 --- a/uninstall.js +++ b/uninstall.js @@ -53,19 +53,5 @@ if (os.platform() == "win32") { // Mac Shortcuts } else if (os.platform() == "darwin") { - // Remove .desktop files - let command = `rm ~/Desktop/${name}.command` - exec( command, - function ( error, stdout ){ - if (error) { - console.log(''); - console.log("There was an error uninstalling shortcuts: "); - console.log(''); - console.log( error ); - return; - } else { - console.log(''); - console.log("Shortcuts have been uninstalled successfully."); - } - }); -} + // Uninstall Mac shortcuts here once they have been added. +} \ No newline at end of file From 2444587978f0518ae9ec9061697d550519410239 Mon Sep 17 00:00:00 2001 From: Oren Kedem Date: Tue, 22 Jun 2021 15:17:01 +0300 Subject: [PATCH 2/5] undo no related change in 'create-shortcut' --- Launch-Scripts/create-shortcut.js | 40 ++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/Launch-Scripts/create-shortcut.js b/Launch-Scripts/create-shortcut.js index bc28e66fb..a7d20db6a 100644 --- a/Launch-Scripts/create-shortcut.js +++ b/Launch-Scripts/create-shortcut.js @@ -92,8 +92,46 @@ if (os.platform() == "win32") { // Mac Shortcuts } else if (os.platform() == "darwin") { - console.log( "Automatic shortcut creation is not yet supported on Mac. If you would like to see this feature add, message @harrellbm on telegram or discord to ask how you can help!") + const icon = path.join( __dirname,"/superalgos.ico"); + const createShortcutCommand = `chmod +x ${name}.command & cp ${name}.command ~/Desktop/${name}.command` + const installFileIconcommand = `npm install fileicon`; + const changeIconCommand = `./node_modules/fileicon/bin/fileicon set ~/Desktop/${name}.command ./Launch-Scripts/superalgos.ico` + const unInstallFileIconcommand = `npm uninstall fileicon`; + + try { + // Create .desktop shortcut file + fs.writeFileSync( `${name}.command`, + `#!/bin/sh + cd ${__dirname} + cd .. + node run + "$SHELL"`, + ); + // Place shortcut in proper folders + execSync( createShortcutCommand,{ timeout: 30000}) + + // Remove temporary .command file + fs.unlinkSync( `${name}.command` ) + + //Install fileicon utility + execSync(installFileIconcommand, {stdio: 'inherit', timeout: 30000}); + + //change Icon + execSync(changeIconCommand, {stdio: 'inherit', timeout: 30000}); + + //Un-Install fileicon utility + execSync(unInstallFileIconcommand, {stdio: 'inherit', timeout: 30000}); + } catch (error) { + console.log(''); + console.log("There was an error installing a shortcut: "); + console.log(''); + console.log( error ); + return; + } + + console.log("Shortcuts added successfully!"); + // Misc Operating System } else { console.log("Automatic shortcut creation is not currently supported on your operating system. If you would like to see your operating system added please reachout on discord or telegram to let the devs know.") From e5511a1b03538d368df835134f4b40e74edab6a1 Mon Sep 17 00:00:00 2001 From: Oren Kedem Date: Tue, 22 Jun 2021 15:17:59 +0300 Subject: [PATCH 3/5] remove extra line --- Launch-Scripts/create-shortcut.js | 1 - 1 file changed, 1 deletion(-) diff --git a/Launch-Scripts/create-shortcut.js b/Launch-Scripts/create-shortcut.js index a7d20db6a..96bb28030 100644 --- a/Launch-Scripts/create-shortcut.js +++ b/Launch-Scripts/create-shortcut.js @@ -131,7 +131,6 @@ if (os.platform() == "win32") { } console.log("Shortcuts added successfully!"); - // Misc Operating System } else { console.log("Automatic shortcut creation is not currently supported on your operating system. If you would like to see your operating system added please reachout on discord or telegram to let the devs know.") From 8b2754ab0a5df3885f32825c9fa137324d16ddf7 Mon Sep 17 00:00:00 2001 From: Oren Kedem Date: Tue, 22 Jun 2021 15:18:51 +0300 Subject: [PATCH 4/5] add extra line --- Launch-Scripts/create-shortcut.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Launch-Scripts/create-shortcut.js b/Launch-Scripts/create-shortcut.js index 96bb28030..c306503fe 100644 --- a/Launch-Scripts/create-shortcut.js +++ b/Launch-Scripts/create-shortcut.js @@ -131,6 +131,7 @@ if (os.platform() == "win32") { } console.log("Shortcuts added successfully!"); + // Misc Operating System } else { console.log("Automatic shortcut creation is not currently supported on your operating system. If you would like to see your operating system added please reachout on discord or telegram to let the devs know.") From 99f69a24c76d0b0806e31d167cebbd92dae9c74c Mon Sep 17 00:00:00 2001 From: Oren Kedem Date: Tue, 22 Jun 2021 15:20:16 +0300 Subject: [PATCH 5/5] fix commit --- uninstall.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/uninstall.js b/uninstall.js index 0203d7e5d..be6ba5d57 100644 --- a/uninstall.js +++ b/uninstall.js @@ -53,5 +53,19 @@ if (os.platform() == "win32") { // Mac Shortcuts } else if (os.platform() == "darwin") { - // Uninstall Mac shortcuts here once they have been added. -} \ No newline at end of file + // Remove .desktop files + let command = `rm ~/Desktop/${name}.command` + exec( command, + function ( error, stdout ){ + if (error) { + console.log(''); + console.log("There was an error uninstalling shortcuts: "); + console.log(''); + console.log( error ); + return; + } else { + console.log(''); + console.log("Shortcuts have been uninstalled successfully."); + } + }); +}