--- a/SelectionInListModelView.st Fri Sep 27 14:16:14 2002 +0200
+++ b/SelectionInListModelView.st Sat Sep 28 06:57:55 2002 +0200
@@ -14,11 +14,11 @@
"{ Package: 'stx:libwidg2' }"
ListModelView subclass:#SelectionInListModelView
- instanceVariableNames:'selection multipleSelectOk actionBlock doubleClickActionBlock
- selectConditionBlock clickLine highlightMode useIndex
- ignoreReselect toggleSelect hilightFgColor hilightBgColor
- hilightLevel hilightFrameColor hilightStyle dragAccessPoint
- dropTarget dropSource editorView openEditorAction'
+ instanceVariableNames:'selection multipleSelectOk selectOnButtomMenu actionBlock
+ doubleClickActionBlock selectConditionBlock clickLine
+ highlightMode useIndex ignoreReselect toggleSelect hilightFgColor
+ hilightBgColor hilightLevel hilightFrameColor hilightStyle
+ dragAccessPoint dropTarget dropSource editorView openEditorAction'
classVariableNames:'DefaultHilightStyle DefaultHilightBackgroundColor
DefaultHilightForegroundColor DefaultHilightLevel
DefaultHilightFrameColor'
@@ -50,20 +50,34 @@
by the model.
[Instance variables:]
- selection <misc> the current selection. nil, a number or collection of numbers
- multipleSelectOk <Boolean> allow/disallow multiple selections( default:false )
- actionBlock <Block> action evaluated on single click
- doubleClickActionBlock <Block> action evaluated on double click
- clickPosition <Point> internal use
- highlightMode <Symbol> how to draw the selection
- useIndex <Boolean> representation of the model selection
- ignoreReselect <Boolean> if set, a click on an already selected entry is ignored
- toggleSelect <Boolean> a click on an entry unselects it and vice versa
- hilightFgColor <Color> foregroundColor of highlighted items
- hilightBgColor <Color> backgroundColor of highlighted items
- hilightLevel <Integer> level to draw selections (i.e. for 3D effect)
- hilightFrameColor <Color> rectangle around highlighted items
- hilightStyle <Boolean> actions on widget are enabled/disabled
+
+ selection <misc> the current selection. nil, a number or collection of numbers
+ multipleSelectOk <Boolean> allow/disallow multiple selections( default:false )
+ selectOnButtomMenu <Boolean> enable/disable selection will change on menu pressed
+
+ actionBlock <Block> action evaluated on single click
+ doubleClickActionBlock <Block> action evaluated on double click
+ selectConditionBlock
+
+ clickLine <Number> clicked line during button motion
+ useIndex <Boolean> representation of the model selection
+
+ ignoreReselect <Boolean> if set, a click on an already selected entry is ignored
+ toggleSelect <Boolean> a click on an entry unselects it and vice versa
+
+ highlightMode <Symbol> how to draw the selection
+ hilightFgColor <Color> foregroundColor of highlighted items
+ hilightBgColor <Color> backgroundColor of highlighted items
+ hilightLevel <Integer> level to draw selections (i.e. for 3D effect)
+ hilightFrameColor <Color> rectangle around highlighted items
+ hilightStyle <Boolean> actions on widget are enabled/disabled
+
+ dragAccessPoint <Point> point where the drag operation starts from
+ dropTarget <DropTarget> keeps information about the drop operation
+ dropSource <DropSource> keeps information about the drag operation
+
+ editorView <View> editor on current selected item
+ openEditorAction <Action> action to get an editor on the current selection from user
[author:]
Claus Atzkern
@@ -73,8 +87,6 @@
ListModelView
HierarchicalListView
"
-
-
!
examples
@@ -351,6 +363,22 @@
multipleSelectOk := aState ? false.
!
+selectOnButtomMenu
+ "define the button-menu-press behavior; if true the line under the mouse
+ will be selected before the menu is opened. Otherwise the menu is opened
+ on the current selection.
+ "
+ ^ selectOnButtomMenu
+!
+
+selectOnButtomMenu:aBoolean
+ "define the button-menu-press behavior; if true the line under the mouse
+ will be selected before the menu is opened. Otherwise the menu is opened
+ on the current selection.
+ "
+ selectOnButtomMenu := aBoolean.
+!
+
toggleSelect
"get the toggleSelect flag - see method #toggleSelect: for more details
"
@@ -882,38 +910,61 @@
buttonPress:button x:x y:y
"a button was pressed - handle selection here
"
- |sensor nsel start step item menu appl isInSelection|
+ |sensor nsel start step item menu appl isInSelection lineNr|
clickLine := nil.
dragAccessPoint := nil.
enabled ifFalse:[^ self].
+ sensor := self sensor.
+ sensor notNil ifTrue:[ lineNr := self yVisibleToLineNr:y ]
+ ifFalse:[ lineNr := nil ].
+
((button == 2) or:[button == #menu]) ifTrue:[
- ( (item := self selectedElement) notNil
- and:[(menu := item perform:#middleButtonMenu ifNotUnderstood:nil) notNil]
- ) ifTrue:[
- menu isCollection ifTrue:[
- menu := Menu new fromLiteralArrayEncoding:menu.
- appl := self application.
+ selectOnButtomMenu ifTrue:[
+ ( lineNr notNil
+ and:[lineNr ~~ self selectedIndex
+ and:[self canSelectIndex:lineNr forAdd:false ]]
+ ) ifTrue:[
+ (self selectWithoutScroll:lineNr redraw:true) ifTrue:[
+ self selectionChanged
+ ].
+ item := self selectedElement.
+ ] ifFalse:[
+ item := nil
+ ]
+ ] ifFalse:[
+ item := self selectedElement.
+ ].
- appl notNil ifTrue:[
- menu findGuiResourcesIn:appl.
- "/ menu receiver:appl -- now done in findGuiResources ...
- ] ifFalse:[
- menu receiver:item
- ]
- ].
- ^ menu startUp
+ item ifNotNil:[
+ item ifNotNil:[ self makeSelectionVisible ].
+
+ menu := item perform:#middleButtonMenu ifNotUnderstood:nil.
+
+ menu ifNotNil:[
+ menu isCollection ifTrue:[
+ menu := Menu new fromLiteralArrayEncoding:menu.
+ appl := self application.
+
+ appl notNil ifTrue:[
+ menu findGuiResourcesIn:appl.
+ "/ menu receiver:appl -- now done in findGuiResources ...
+ ] ifFalse:[
+ menu receiver:item
+ ]
+ ].
+ menu startUp.
+ ^ self
+ ]
].
- ^ super buttonPress:button x:x y:y
+ super buttonPress:button x:x y:y.
+ ^ self
].
- ( (sensor := self sensor) isNil
- or:[(clickLine := self yVisibleToLineNr:y) isNil]
- ) ifTrue:[
- ^ self
- ].
+ (clickLine := lineNr) ifNil:[ ^ self ].
+
isInSelection := self isInSelection:clickLine.
multipleSelectOk ifTrue:[
@@ -1212,18 +1263,13 @@
initStyle
"setup viewStyle specifics
"
- |h|
-
super initStyle.
- DefaultHilightLevel isNil ifTrue:[
- self updateStyleCache
- ].
-
- hilightFrameColor := nil.
- hilightStyle := DefaultHilightStyle.
- highlightMode := #label.
- textStartLeft := 4.
+ hilightFrameColor := nil.
+ hilightStyle := DefaultHilightStyle.
+ highlightMode := #label.
+ textStartLeft := 4.
+ selectOnButtomMenu := false.
super font:(styleSheet fontAt:#'selection.font').
@@ -1685,5 +1731,5 @@
!SelectionInListModelView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.51 2002-09-27 11:53:27 penk Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.52 2002-09-28 04:57:55 ca Exp $'
! !