# HG changeset patch # User ca # Date 883757256 -3600 # Node ID 663a913ec30b42ff4110738640ba3c5d13ffe47a # Parent 2e9b198375905cdf3c2ce35caf9f7ef18be2e4ba discard motion events if +/- is pressed diff -r 2e9b19837590 -r 663a913ec30b SelTreeV.st --- a/SelTreeV.st Fri Jan 02 17:06:32 1998 +0100 +++ b/SelTreeV.st Fri Jan 02 17:07:36 1998 +0100 @@ -16,7 +16,8 @@ showLines listOfNodes imageInset textInset labelOffsetY openIndicator computeResources closeIndicator showRoot extentOpenIndicator extentCloseIndicator showDirectoryIndicator - indicatorExtentDiv2 imageOpened imageClosed imageItem' + indicatorExtentDiv2 imageOpened imageClosed imageItem + discardMotionEvents' classVariableNames:'ImageOpened ImageClosed ImageItem OpenIndicator CloseIndicator' poolDictionaries:'' category:'Views-Text' @@ -568,6 +569,16 @@ !SelectionInTreeView methodsFor:'event handling'! +buttonMotion:buttonMask x:x y:y + "mouse-move while button was pressed - handle selection changes" + + discardMotionEvents ifFalse:[ + super buttonMotion:buttonMask x:x y:y + ] + + +! + buttonMultiPress:button x:x y:y (self indicatiorLineForButton:button atX:x y:y) == 0 ifTrue:[ @@ -579,7 +590,7 @@ buttonPress:button x:x y:y "check for indicator " - |expand node lineNr selNode newSel size oldSelection| + |expand node lineNr| lineNr := self indicatiorLineForButton:button atX:x y:y. @@ -593,62 +604,30 @@ ) ifFalse:[ ^ super buttonPress:button x:x y:y ]. - + discardMotionEvents := true. dragIsActive := false. clickPosition := nil. - expand := node isExpandable. - (size := self numberOfSelections) == 0 ifTrue:[ "/ nothing selected - ^ self nodeAt:lineNr expand:expand. - ]. - oldSelection := selection. - - size == 1 ifTrue:[ "/ single selection - selNode := self selectedNode. - - lineNr >= self selectedIndex ifTrue:[ "/ operation will not changed - ^ self nodeAt:lineNr expand:expand. "/ current selected index - ]. - model setSelectionIndex:0. "/ selected index will change - self selectWithoutScroll:nil. - - self nodeAt:lineNr expand:expand. - size := self indexOfNode:selNode. - - size == 0 ifTrue:[ "/ old selection no longer visible - ^ self selection:lineNr "/ change selection; raise notify - ]. - self selectWithoutScroll:size. "/ can keep old selection - model setSelectionIndex:selection. "/ but has to change index - ^ self selectionChangedFrom:oldSelection - ]. - selNode := OrderedCollection new:size. - newSel := OrderedCollection new:size. - - self selectionDo:[:i| - selNode add:(listOfNodes at:i) "/ change selection to nodes - ]. - model setSelectionIndex:0. "/ redraw current selection unselected - self selectWithoutScroll:nil. - self nodeAt:lineNr expand:expand. "/ perform expand/collapse operation - - selNode do:[:n||i| "/ convert old selection to new selection - (i := self indexOfNode:n) ~~ 0 ifTrue:[ - newSel add:i "/ can take over into new selection + self hasSelection ifTrue:[ + (selectConditionBlock isNil or:[selectConditionBlock value:lineNr]) ifTrue:[ + self selection:lineNr + ] ifFalse:[ + self selection:nil ] ]. + self nodeAt:lineNr expand:(node isExpandable). - newSel isEmpty ifTrue:[ "/ old selection no longer visible - ^ self selection:lineNr "/ change selection; raise notify - ]. +! + +buttonRelease:button x:x y:y + "stop any autoscroll" - newSel size == size ifTrue:[ - self selectWithoutScroll:newSel. "/ can keep old selection - model setSelectionIndex:selection. "/ but has to change indeces - self selectionChangedFrom:oldSelection. - ] ifFalse:[ - self selection:newSel "/ can keep part of old selection - ] + discardMotionEvents ifTrue:[ + clickPosition := nil. + discardMotionEvents := false. + ]. + super buttonRelease:button x:x y:y + ! doubleClicked @@ -764,6 +743,8 @@ showRoot := true. computeResources := true. showDirectoryIndicator := false. + discardMotionEvents := false. + textInset := 2. imageInset := 0. "/ set during indication enabled imageWidth := 8. "/ default: will change during startup @@ -1343,5 +1324,5 @@ !SelectionInTreeView class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libwidg2/Attic/SelTreeV.st,v 1.31 1997-11-19 16:32:08 cg Exp $' + ^ '$Header: /cvs/stx/stx/libwidg2/Attic/SelTreeV.st,v 1.32 1998-01-02 16:07:36 ca Exp $' ! ! diff -r 2e9b19837590 -r 663a913ec30b SelectionInTreeView.st --- a/SelectionInTreeView.st Fri Jan 02 17:06:32 1998 +0100 +++ b/SelectionInTreeView.st Fri Jan 02 17:07:36 1998 +0100 @@ -16,7 +16,8 @@ showLines listOfNodes imageInset textInset labelOffsetY openIndicator computeResources closeIndicator showRoot extentOpenIndicator extentCloseIndicator showDirectoryIndicator - indicatorExtentDiv2 imageOpened imageClosed imageItem' + indicatorExtentDiv2 imageOpened imageClosed imageItem + discardMotionEvents' classVariableNames:'ImageOpened ImageClosed ImageItem OpenIndicator CloseIndicator' poolDictionaries:'' category:'Views-Text' @@ -568,6 +569,16 @@ !SelectionInTreeView methodsFor:'event handling'! +buttonMotion:buttonMask x:x y:y + "mouse-move while button was pressed - handle selection changes" + + discardMotionEvents ifFalse:[ + super buttonMotion:buttonMask x:x y:y + ] + + +! + buttonMultiPress:button x:x y:y (self indicatiorLineForButton:button atX:x y:y) == 0 ifTrue:[ @@ -579,7 +590,7 @@ buttonPress:button x:x y:y "check for indicator " - |expand node lineNr selNode newSel size oldSelection| + |expand node lineNr| lineNr := self indicatiorLineForButton:button atX:x y:y. @@ -593,62 +604,30 @@ ) ifFalse:[ ^ super buttonPress:button x:x y:y ]. - + discardMotionEvents := true. dragIsActive := false. clickPosition := nil. - expand := node isExpandable. - (size := self numberOfSelections) == 0 ifTrue:[ "/ nothing selected - ^ self nodeAt:lineNr expand:expand. - ]. - oldSelection := selection. - - size == 1 ifTrue:[ "/ single selection - selNode := self selectedNode. - - lineNr >= self selectedIndex ifTrue:[ "/ operation will not changed - ^ self nodeAt:lineNr expand:expand. "/ current selected index - ]. - model setSelectionIndex:0. "/ selected index will change - self selectWithoutScroll:nil. - - self nodeAt:lineNr expand:expand. - size := self indexOfNode:selNode. - - size == 0 ifTrue:[ "/ old selection no longer visible - ^ self selection:lineNr "/ change selection; raise notify - ]. - self selectWithoutScroll:size. "/ can keep old selection - model setSelectionIndex:selection. "/ but has to change index - ^ self selectionChangedFrom:oldSelection - ]. - selNode := OrderedCollection new:size. - newSel := OrderedCollection new:size. - - self selectionDo:[:i| - selNode add:(listOfNodes at:i) "/ change selection to nodes - ]. - model setSelectionIndex:0. "/ redraw current selection unselected - self selectWithoutScroll:nil. - self nodeAt:lineNr expand:expand. "/ perform expand/collapse operation - - selNode do:[:n||i| "/ convert old selection to new selection - (i := self indexOfNode:n) ~~ 0 ifTrue:[ - newSel add:i "/ can take over into new selection + self hasSelection ifTrue:[ + (selectConditionBlock isNil or:[selectConditionBlock value:lineNr]) ifTrue:[ + self selection:lineNr + ] ifFalse:[ + self selection:nil ] ]. + self nodeAt:lineNr expand:(node isExpandable). - newSel isEmpty ifTrue:[ "/ old selection no longer visible - ^ self selection:lineNr "/ change selection; raise notify - ]. +! + +buttonRelease:button x:x y:y + "stop any autoscroll" - newSel size == size ifTrue:[ - self selectWithoutScroll:newSel. "/ can keep old selection - model setSelectionIndex:selection. "/ but has to change indeces - self selectionChangedFrom:oldSelection. - ] ifFalse:[ - self selection:newSel "/ can keep part of old selection - ] + discardMotionEvents ifTrue:[ + clickPosition := nil. + discardMotionEvents := false. + ]. + super buttonRelease:button x:x y:y + ! doubleClicked @@ -764,6 +743,8 @@ showRoot := true. computeResources := true. showDirectoryIndicator := false. + discardMotionEvents := false. + textInset := 2. imageInset := 0. "/ set during indication enabled imageWidth := 8. "/ default: will change during startup @@ -1343,5 +1324,5 @@ !SelectionInTreeView class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.31 1997-11-19 16:32:08 cg Exp $' + ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.32 1998-01-02 16:07:36 ca Exp $' ! !