Bladeren bron

mol-plugin: fix selectToggle, bind unselect to secondary button

David Sehnal 5 jaren geleden
bovenliggende
commit
0964a9fd50
2 gewijzigde bestanden met toevoegingen van 6 en 2 verwijderingen
  1. 2 2
      src/mol-plugin/behavior/dynamic/representation.ts
  2. 4 0
      src/mol-plugin/util/interactivity.ts

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

@@ -77,9 +77,9 @@ const DefaultSelectLociBindings = {
     clickSelect: Binding.Empty,
     clickSelectExtend: Binding([Trigger(B.Flag.Primary, M.create({ shift: true }))], 'Extend selection to clicked element along polymer using ${triggers}.'),
     clickSelectOnly: Binding.Empty,
-    clickSelectToggle: Binding([Trigger(B.Flag.Primary, M.create())], 'Toggle selection of clicked element using ${triggers}.'),
+    clickSelectToggle: Binding([Trigger(B.Flag.Primary)], 'Toggle selection of clicked element using ${triggers}.'),
     clickDeselect: Binding.Empty,
-    clickDeselectAllOnEmpty: Binding([Trigger(B.Flag.Primary)], 'Deselect all when clicking on nothing using ${triggers}.'),
+    clickDeselectAllOnEmpty: Binding([Trigger(B.Flag.Secondary)], 'Deselect all when clicking on nothing using ${triggers}.'),
 }
 const SelectLociParams = {
     bindings: PD.Value(DefaultSelectLociBindings, { isHidden: true }),

+ 4 - 0
src/mol-plugin/util/interactivity.ts

@@ -135,6 +135,8 @@ namespace Interactivity {
 
     export class LociSelectManager extends LociMarkManager {
         selectToggle(current: Loci<ModelLoci>, applyGranularity = true) {
+            if (ModelLoci.isEmpty(current.loci)) return;
+
             const normalized = this.normalizedLoci(current, applyGranularity)
             if (StructureElement.Loci.is(normalized.loci)) {
                 this.toggleSel(normalized);
@@ -144,6 +146,8 @@ namespace Interactivity {
         }
 
         selectExtend(current: Loci<ModelLoci>, applyGranularity = true) {
+            if (ModelLoci.isEmpty(current.loci)) return;
+
             const normalized = this.normalizedLoci(current, applyGranularity)
             if (StructureElement.Loci.is(normalized.loci)) {
                 const loci = this.sel.tryGetRange(normalized.loci) || normalized.loci;