Browse Source

mouse binding fixes

Alexander Rose 5 years ago
parent
commit
ad619d9b8d

+ 12 - 9
src/mol-plugin/behavior/dynamic/representation.ts

@@ -27,7 +27,7 @@ const Trigger = Binding.Trigger
 //
 
 const DefaultHighlightLociBindings = {
-    hoverHighlightOnly: Binding([Trigger(B.Flag.None)], 'Highlight hovered element using ${triggers}'),
+    hoverHighlightOnly: Binding([Trigger(B.Flag.None, M.create())], 'Highlight hovered element using ${triggers}'),
     hoverHighlightOnlyExtend: Binding([Trigger(B.Flag.None, M.create({ shift: true }))], 'Extend highlight from selected to hovered element along polymer using ${triggers}'),
 }
 const HighlightLociParams = {
@@ -111,13 +111,16 @@ export const SelectLoci = PluginBehavior.create({
             }
         }
         register() {
+            const lociIsEmpty = (current: Interactivity.Loci) => Loci.isEmpty(current.loci)
+            const lociIsNotEmpty = (current: Interactivity.Loci) => !Loci.isEmpty(current.loci)
+
             const actions: [keyof typeof DefaultSelectLociBindings, (current: Interactivity.Loci) => void, ((current: Interactivity.Loci) => boolean) | undefined][] = [
-                ['clickSelect', current => this.ctx.interactivity.lociSelects.select(current), void 0],
-                ['clickToggle', current => this.ctx.interactivity.lociSelects.toggle(current), void 0],
-                ['clickToggleExtend', current => this.ctx.interactivity.lociSelects.toggleExtend(current), void 0],
-                ['clickSelectOnly', current => this.ctx.interactivity.lociSelects.selectOnly(current), void 0],
-                ['clickDeselect', current => this.ctx.interactivity.lociSelects.deselect(current), void 0],
-                ['clickDeselectAllOnEmpty', () => this.ctx.interactivity.lociSelects.deselectAll(), current => Loci.isEmpty(current.loci)],
+                ['clickSelect', current => this.ctx.interactivity.lociSelects.select(current), lociIsNotEmpty],
+                ['clickToggle', current => this.ctx.interactivity.lociSelects.toggle(current), lociIsNotEmpty],
+                ['clickToggleExtend', current => this.ctx.interactivity.lociSelects.toggleExtend(current), lociIsNotEmpty],
+                ['clickSelectOnly', current => this.ctx.interactivity.lociSelects.selectOnly(current), lociIsNotEmpty],
+                ['clickDeselect', current => this.ctx.interactivity.lociSelects.deselect(current), lociIsNotEmpty],
+                ['clickDeselectAllOnEmpty', () => this.ctx.interactivity.lociSelects.deselectAll(), lociIsEmpty],
             ];
 
             // sort the action so that the ones with more modifiers trigger sooner.
@@ -128,12 +131,12 @@ export const SelectLoci = PluginBehavior.create({
                 return l - k;
             })
 
-            this.subscribeObservable(this.ctx.behaviors.interaction.click, ({ current, buttons, modifiers }) => {
+            this.subscribeObservable(this.ctx.behaviors.interaction.click, ({ current, button, modifiers }) => {
                 if (!this.ctx.canvas3d) return
 
                 // only trigger the 1st action that matches
                 for (const [binding, action, condition] of actions) {
-                    if (Binding.match(this.params.bindings[binding], buttons, modifiers) && (!condition || condition(current))) {
+                    if (Binding.match(this.params.bindings[binding], button, modifiers) && (!condition || condition(current))) {
                         action(current);
                         break;
                     }

+ 2 - 2
src/mol-plugin/behavior/dynamic/selection/structure-representation-interaction.ts

@@ -133,10 +133,10 @@ export class StructureRepresentationInteractionBehavior extends PluginBehavior.W
             }
         });
 
-        this.subscribeObservable(this.plugin.behaviors.interaction.click, ({ current, buttons, modifiers }) => {
+        this.subscribeObservable(this.plugin.behaviors.interaction.click, ({ current, button, modifiers }) => {
             const { clickInteractionAroundOnly } = this.params.bindings
 
-            if (Binding.match(clickInteractionAroundOnly, buttons, modifiers)) {
+            if (Binding.match(clickInteractionAroundOnly, button, modifiers)) {
                 if (isEmptyLoci(current.loci)) {
                     this.clear(StateTransform.RootRef);
                     lastLoci = current.loci;

+ 2 - 2
src/mol-plugin/behavior/dynamic/volume-streaming/behavior.ts

@@ -246,8 +246,8 @@ export namespace VolumeStreaming {
                 }
             });
 
-            this.subscribeObservable(this.plugin.behaviors.interaction.click, ({ current, buttons, modifiers }) => {
-                if (!Binding.match((this.params.bindings && this.params.bindings.clickVolumeAroundOnly) || DefaultBindings.clickVolumeAroundOnly, buttons, modifiers)) return;
+            this.subscribeObservable(this.plugin.behaviors.interaction.click, ({ current, button, modifiers }) => {
+                if (!Binding.match((this.params.bindings && this.params.bindings.clickVolumeAroundOnly) || DefaultBindings.clickVolumeAroundOnly, button, modifiers)) return;
                 if (this.params.entry.params.view.name !== 'selection-box') {
                     this.lastLoci = this.getNormalizedLoci(current.loci);
                 } else {