lists.squeakfoundation.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Packages
November 2011
----- 2024 -----
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
packages@lists.squeakfoundation.org
1 participants
159 discussions
Start a n
N
ew thread
The Trunk: Morphic-cmm.584.mcz
by commits@source.squeak.org
08 Nov '11
08 Nov '11
Chris Muller uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-cmm.584.mcz
==================== Summary ==================== Name: Morphic-cmm.584 Author: cmm Time: 17 October 2011, 11:08:24.053 pm UUID: 35c31015-f644-4f27-93d1-11ae65b89cbe Ancestors: Morphic-cmm.578, Morphic-Richo.583 Merged to Richo.583. =============== Diff against Morphic-Richo.583 =============== Item was changed: ScrollPane subclass: #PluggableListMorph + instanceVariableNames: 'list getListSelector getListSizeSelector getListElementSelector getIndexSelector setIndexSelector keystrokeActionSelector autoDeselect lastKeystrokeTime lastKeystrokes lastClickTime doubleClickSelector handlesBasicKeys potentialDropRow listMorph hScrollRangeCache keystrokePreviewSelector priorSelection' + classVariableNames: 'FilterableLists' - instanceVariableNames: 'list getListSelector getListSizeSelector getListElementSelector getIndexSelector setIndexSelector keystrokeActionSelector autoDeselect lastKeystrokeTime lastKeystrokes lastClickTime doubleClickSelector handlesBasicKeys potentialDropRow listMorph hScrollRangeCache keystrokePreviewSelector' - classVariableNames: '' poolDictionaries: '' category: 'Morphic-Pluggable Widgets'! + !PluggableListMorph commentStamp: 'cmm 8/21/2011 23:37' prior: 0! + When a PluggableListMorph is in focus, type in a letter (or several letters quickly) to go to the next item that begins with that letter (if FilterableLists is false). - !PluggableListMorph commentStamp: '<historical>' prior: 0! - ... - When a PluggableListMorph is in focus, type in a letter (or several - letters quickly) to go to the next item that begins with that letter. Special keys (up, down, home, etc.) are also supported.! Item was added: + ----- Method: PluggableListMorph class>>filterableLists (in category 'preferences') ----- + filterableLists + <preference: 'Filterable Lists' + category: 'scrolling' + description: 'When true, using the keyboard on a list will filter it rather than scroll. Pressing enter or backspace restores all items to the list.' + type: #Boolean> + ^ FilterableLists ifNil: [ true ]! Item was added: + ----- Method: PluggableListMorph class>>filterableLists: (in category 'preferences') ----- + filterableLists: aBoolean + "When true, using the keyboard on a list will filter it rather than scroll. Pressing enter or backspace restores all items to the list." + FilterableLists := aBoolean! Item was changed: ----- Method: PluggableListMorph>>basicKeyPressed: (in category 'model access') ----- basicKeyPressed: aChar - | milliseconds slowKeyStroke listSize newSelectionIndex oldSelectionIndex startIndex | oldSelectionIndex := newSelectionIndex := self getCurrentSelectionIndex. listSize := self getListSize. milliseconds := Time millisecondClockValue. + slowKeyStroke := (Time + milliseconds: milliseconds + since: lastKeystrokeTime) > (self class filterableLists ifTrue: [500] ifFalse: [ 300 ]). - slowKeyStroke := (Time milliseconds: milliseconds since: lastKeystrokeTime) > 300. lastKeystrokeTime := milliseconds. slowKeyStroke + ifTrue: + [ self class filterableLists ifTrue: [ self hasFilter ifFalse: [ priorSelection := self modelIndexFor: self selectionIndex] ]. + "forget previous keystrokes and search in following elements" - ifTrue: ["forget previous keystrokes and search in following elements" lastKeystrokes := aChar asLowercase asString. + newSelectionIndex := newSelectionIndex \\ listSize + 1. + self class filterableLists ifTrue: [ list := self getFullList ] ] + ifFalse: [ "append quick keystrokes but don't move selection if it still matches" - newSelectionIndex := newSelectionIndex \\ listSize + 1 ] - ifFalse: ["append quick keystrokes but don't move selection if it still matches" lastKeystrokes := lastKeystrokes , aChar asLowercase asString. newSelectionIndex := newSelectionIndex max: 1 ]. "No change if model is locked" + model okToChange ifFalse: [ ^ self ]. + self class filterableLists + ifTrue: + [ self + filterList ; + updateList. + newSelectionIndex := self modelIndexFor: 1 ] + ifFalse: + [ startIndex := newSelectionIndex. + listSize := self getListSize. + [ (self getListItem: newSelectionIndex) asString withBlanksTrimmed asLowercase beginsWith: lastKeystrokes ] whileFalse: + [ (newSelectionIndex := newSelectionIndex \\ listSize + 1) = startIndex ifTrue: [ ^ self flash"Not in list." ] ]. + newSelectionIndex = oldSelectionIndex ifTrue: [ ^ self flash ] ]. + (self hasFilter and: [(self getCurrentSelectionIndex = newSelectionIndex) not]) ifTrue: + [self changeModelSelection: newSelectionIndex]! - model okToChange ifFalse: [ ^self ]. - "Get rid of blanks and style used in some lists" - startIndex := newSelectionIndex. - [ - (self getListItem: newSelectionIndex) asString - withBlanksTrimmed asLowercase beginsWith: lastKeystrokes ] - whileFalse: [ - (newSelectionIndex := newSelectionIndex \\ listSize + 1) = startIndex ifTrue: [ - ^self flash. "Not in list." ] ]. - newSelectionIndex = oldSelectionIndex ifTrue: [ ^self flash ]. "Same selection." - ^self changeModelSelection: newSelectionIndex! Item was added: + ----- Method: PluggableListMorph>>filterList (in category 'filtering') ----- + filterList + self hasFilter + ifTrue: + [ | frontMatching substringMatching newList | + self indicateFiltered. + frontMatching := OrderedCollection new. + substringMatching := OrderedCollection new. + list withIndexDo: + [ : each : n | | foundPos | + foundPos := each asString + findString: lastKeystrokes + startingAt: 1 + caseSensitive: false. + foundPos = 1 + ifTrue: [ frontMatching add: each ] + ifFalse: + [ foundPos = 0 ifFalse: [ substringMatching add: each ] ] ]. + newList := frontMatching , substringMatching. + newList + ifEmpty: + [ lastKeystrokes := lastKeystrokes allButLast: 1. + self + flash ; + filterList ] + ifNotEmpty: [ list := newList ] ] + ifFalse: [ self indicateUnfiltered ]! Item was added: + ----- Method: PluggableListMorph>>getFullList (in category 'model access') ----- + getFullList + "The full, unfiltered list." + ^ model perform: getListSelector! Item was changed: ----- Method: PluggableListMorph>>getList (in category 'model access') ----- getList "Answer the list to be displayed. Caches the returned list in the 'list' ivar" + getListSelector == nil ifTrue: [ ^ Array empty ]. + list := self getFullList. + self class filterableLists ifTrue: [ self filterList ]. - getListSelector == nil ifTrue: [ ^ #() ]. - list := model perform: getListSelector. ^ list ifNil: [ Array empty ]! Item was added: + ----- Method: PluggableListMorph>>hasFilter (in category 'filtering') ----- + hasFilter + ^ lastKeystrokes isEmptyOrNil not! Item was added: + ----- Method: PluggableListMorph>>indicateFiltered (in category 'filtering') ----- + indicateFiltered + self color: Color red muchLighter muchLighter! Item was added: + ----- Method: PluggableListMorph>>indicateUnfiltered (in category 'filtering') ----- + indicateUnfiltered + self color: Color white! Item was added: + ----- Method: PluggableListMorph>>modelIndexFor: (in category 'selection') ----- + modelIndexFor: selectionIndex + "The model does not know anything about the receiver's filtering, so if I am filtered, we must determine the correct index by scanning the full list in the model." + ^ (selectionIndex > 0 and: [ self hasFilter ]) + ifTrue: + [ list + ifEmpty: [ 0 ] + ifNotEmpty: [ self getFullList indexOf: (self getListItem: selectionIndex) ] ] + ifFalse: [ selectionIndex ]! Item was changed: ----- Method: PluggableListMorph>>mouseUp: (in category 'events') ----- mouseUp: event "The mouse came up within the list; take appropriate action" | row | row := self rowAtLocation: event position. "aMorph ifNotNil: [aMorph highlightForMouseDown: false]." model okToChange ifFalse: [^ self]. "No change if model is locked" row = self selectionIndex ifTrue: [(autoDeselect ifNil: [true]) ifTrue:[row = 0 ifFalse: [self changeModelSelection: 0] ]] + ifFalse: [self changeModelSelection: (self modelIndexFor: row)]. - ifFalse: [self changeModelSelection: row]. Cursor normal show! Item was added: + ----- Method: PluggableListMorph>>removeFilter (in category 'model access') ----- + removeFilter + lastKeystrokes := String empty. + list := nil! Item was changed: ----- Method: PluggableListMorph>>scrollSelectionIntoView (in category 'selection') ----- scrollSelectionIntoView "make sure that the current selection is visible" | row | + row := self uiIndexFor: self getCurrentSelectionIndex. - row := self getCurrentSelectionIndex. row = 0 ifTrue: [ ^ self ]. self scrollToShow: (self listMorph drawBoundsForRow: row)! Item was changed: ----- Method: PluggableListMorph>>selectedMorph: (in category 'selection') ----- selectedMorph: aMorph "this shouldn't be used any longer" + self isThisEverCalled . - "self isThisEverCalled ." - - Beeper beep. true ifTrue: [^self]! Item was changed: ----- Method: PluggableListMorph>>setSelectedMorph: (in category 'selection') ----- + setSelectedMorph: aMorph + self changeModelSelection: (self modelIndexFor: (scroller submorphs indexOf: aMorph))! - setSelectedMorph: aMorph - self changeModelSelection: (scroller submorphs indexOf: aMorph)! Item was changed: ----- Method: PluggableListMorph>>specialKeyPressed: (in category 'model access') ----- specialKeyPressed: asciiValue "A special key with the given ascii-value was pressed; dispatch it" - | oldSelection nextSelection max howManyItemsShowing | + (#(8 13) includes: asciiValue) ifTrue: + [ "backspace key - clear the filter, restore the list with the selection" + self removeFilter. + priorSelection ifNotNil: [ asciiValue = 8 ifTrue: [ self changeModelSelection: priorSelection ] ]. + ^ self updateList ]. asciiValue = 27 ifTrue: [" escape key" ^ ActiveEvent shiftPressed ifTrue: [ActiveWorld putUpWorldMenuFromEscapeKey] ifFalse: [self yellowButtonActivity: false]]. max := self maximumSelection. max > 0 ifFalse: [^ self]. + nextSelection := oldSelection := self selectionIndex. - nextSelection := oldSelection := self getCurrentSelectionIndex. asciiValue = 31 ifTrue: [" down arrow" nextSelection := oldSelection + 1. nextSelection > max ifTrue: [nextSelection := 1]]. asciiValue = 30 ifTrue: [" up arrow" nextSelection := oldSelection - 1. nextSelection < 1 ifTrue: [nextSelection := max]]. asciiValue = 1 ifTrue: [" home" nextSelection := 1]. asciiValue = 4 ifTrue: [" end" nextSelection := max]. howManyItemsShowing := self numSelectionsInView. asciiValue = 11 ifTrue: [" page up" nextSelection := 1 max: oldSelection - howManyItemsShowing]. asciiValue = 12 ifTrue: [" page down" nextSelection := oldSelection + howManyItemsShowing min: max]. model okToChange ifFalse: [^ self]. "No change if model is locked" oldSelection = nextSelection ifTrue: [^ self flash]. + ^ self changeModelSelection: (self modelIndexFor: nextSelection)! - ^ self changeModelSelection: nextSelection! Item was removed: - ----- Method: PluggableListMorph>>superDrawOn: (in category 'drawing') ----- - superDrawOn: aCanvas - super drawOn: aCanvas. - ! Item was added: + ----- Method: PluggableListMorph>>uiIndexFor: (in category 'selection') ----- + uiIndexFor: modelIndex + "The model does not know anything about the receiver's filtering. Answer the index in my (possibly filtered) list for modelIndex." + (modelIndex > 0 and: [ self hasFilter ]) + ifTrue: + [ | selectedItem | + selectedItem := self getFullList at: modelIndex. + (list ifNil: [ self getList ]) withIndexDo: + [ : eachMatchingItem : n | eachMatchingItem = selectedItem ifTrue: [ ^ n ] ]. + ^ 0 ] + ifFalse: [ ^ modelIndex ]! Item was changed: ----- Method: PluggableListMorph>>update: (in category 'updating') ----- update: aSymbol "Refer to the comment in View|update:." + aSymbol == getListSelector ifTrue: + [ self updateList. + ^ self ]. - - aSymbol == getListSelector ifTrue: - [self updateList. - ^ self]. aSymbol == getIndexSelector ifTrue: + [ | uiIndex modelIndex | + uiIndex := self uiIndexFor: (modelIndex := self getCurrentSelectionIndex). + self selectionIndex: + (uiIndex = 0 + ifTrue: + [ "The filter is preventing us from selecting the item we want - remove it." + (list notNil and: [list size > 0]) ifTrue: [ self removeFilter ]. + modelIndex ] + ifFalse: [ uiIndex ]). + ^ self ]! - [self selectionIndex: self getCurrentSelectionIndex. - ^ self]. - ! Item was changed: ----- Method: PluggableListMorph>>updateList (in category 'updating') ----- updateList | index | "the list has changed -- update from the model" self listMorph listChanged. self setScrollDeltas. scrollBar setValue: 0.0. index := self getCurrentSelectionIndex. self resetPotentialDropRow. + self selectionIndex: (self uiIndexFor: index). - self selectionIndex: index. ! Item was changed: ----- Method: PluggableListMorph>>verifyContents (in category 'updating') ----- verifyContents "Verify the contents of the receiver, reconstituting if necessary. Called whenever window is reactivated, to react to possible structural changes. Also called periodically in morphic if the smartUpdating preference is true" | newList existingSelection anIndex oldList | oldList := list ifNil: [ #() ]. newList := self getList. oldList = newList ifTrue: [ ^ self ]. existingSelection := self selectionIndex > 0 ifTrue: [ oldList at: self selectionIndex ] ifFalse: [ nil ]. self updateList. + (existingSelection notNil and: [(anIndex := self getFullList indexOf: existingSelection asStringOrText ifAbsent: [nil]) notNil]) - (existingSelection notNil and: [(anIndex := list indexOf: existingSelection asStringOrText ifAbsent: [nil]) notNil]) ifTrue: [model noteSelectionIndex: anIndex for: getListSelector. self selectionIndex: anIndex] ifFalse: [self changeModelSelection: 0]! Item was changed: ----- Method: PluggableListMorphOfMany>>mouseDown: (in category 'event handling') ----- mouseDown: event | oldIndex oldVal row | event yellowButtonPressed ifTrue: [^ self yellowButtonActivity: event shiftPressed]. row := self rowAtLocation: event position. row = 0 ifTrue: [^super mouseDown: event]. model okToChange ifFalse: [^ self]. "No change if model is locked" "Set meaning for subsequent dragging of selection" dragOnOrOff := (self listSelectionAt: row) not. oldIndex := self getCurrentSelectionIndex. oldIndex ~= 0 ifTrue: [oldVal := self listSelectionAt: oldIndex]. "Set or clear new primary selection (listIndex)" dragOnOrOff + ifTrue: [self changeModelSelection: (self modelIndexFor: row)] - ifTrue: [self changeModelSelection: row] ifFalse: [self changeModelSelection: 0]. "Need to restore the old one, due to how model works, and set new one." oldIndex ~= 0 ifTrue: [self listSelectionAt: oldIndex put: oldVal]. self listSelectionAt: row put: dragOnOrOff. "event hand releaseMouseFocus: aMorph." "aMorph changed"! Item was changed: ----- Method: PluggableListMorphOfMany>>mouseMove: (in category 'event handling') ----- mouseMove: event "The mouse has moved, as characterized by the event provided. Adjust the scrollbar, and alter the selection as appropriate" | oldIndex oldVal row | event position y < self top ifTrue: [scrollBar scrollUp: 1. row := self rowAtLocation: scroller topLeft + (1 @ 1)] ifFalse: [row := event position y > self bottom ifTrue: [scrollBar scrollDown: 1. self rowAtLocation: scroller bottomLeft + (1 @ -1)] ifFalse: [ self rowAtLocation: event position]]. row = 0 ifTrue: [^super mouseDown: event]. model okToChange ifFalse: [^self]. "No change if model is locked" dragOnOrOff ifNil: ["Was not set at mouse down, which means the mouse must have gone down in an area where there was no list item" dragOnOrOff := (self listSelectionAt: row) not]. "Set meaning for subsequent dragging of selection" oldIndex := self getCurrentSelectionIndex. oldIndex ~= 0 ifTrue: [oldVal := self listSelectionAt: oldIndex]. "Set or clear new primary selection (listIndex)" dragOnOrOff + ifTrue: [self changeModelSelection: (self modelIndexFor: row)] - ifTrue: [self changeModelSelection: row] ifFalse: [self changeModelSelection: 0]. "Need to restore the old one, due to how model works, and set new one." oldIndex ~= 0 ifTrue: [self listSelectionAt: oldIndex put: oldVal]. self listSelectionAt: row put: dragOnOrOff. row changed!
1
0
0
0
The Trunk: Morphic-cmm.585.mcz
by commits@source.squeak.org
08 Nov '11
08 Nov '11
Chris Muller uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-cmm.585.mcz
==================== Summary ==================== Name: Morphic-cmm.585 Author: cmm Time: 18 October 2011, 8:59:46.678 pm UUID: 96995b99-2105-4626-8c97-3ad777abf75d Ancestors: Morphic-cmm.584 - Added 'Filterable Lists Clear Automatically' preference. When using the Filterable Lists option, if this option is also selected, then the filter will be cleared as soon as the list loses keyboard focus. =============== Diff against Morphic-Richo.583 =============== Item was changed: ScrollPane subclass: #PluggableListMorph + instanceVariableNames: 'list getListSelector getListSizeSelector getListElementSelector getIndexSelector setIndexSelector keystrokeActionSelector autoDeselect lastKeystrokeTime lastKeystrokes lastClickTime doubleClickSelector handlesBasicKeys potentialDropRow listMorph hScrollRangeCache keystrokePreviewSelector priorSelection' + classVariableNames: 'ClearFilterAutomatically FilterableLists' - instanceVariableNames: 'list getListSelector getListSizeSelector getListElementSelector getIndexSelector setIndexSelector keystrokeActionSelector autoDeselect lastKeystrokeTime lastKeystrokes lastClickTime doubleClickSelector handlesBasicKeys potentialDropRow listMorph hScrollRangeCache keystrokePreviewSelector' - classVariableNames: '' poolDictionaries: '' category: 'Morphic-Pluggable Widgets'! + !PluggableListMorph commentStamp: 'cmm 8/21/2011 23:37' prior: 0! + When a PluggableListMorph is in focus, type in a letter (or several letters quickly) to go to the next item that begins with that letter (if FilterableLists is false). - !PluggableListMorph commentStamp: '<historical>' prior: 0! - ... - When a PluggableListMorph is in focus, type in a letter (or several - letters quickly) to go to the next item that begins with that letter. Special keys (up, down, home, etc.) are also supported.! Item was added: + ----- Method: PluggableListMorph class>>clearFilterAutomatically (in category 'preferences') ----- + clearFilterAutomatically + <preference: 'Filterable Lists Clear Automatically' + category: 'scrolling' + description: 'When using the Filterable Lists option, if this option is also selected, then the filter will be cleared as soon as the list loses keyboard focus.' + type: #Boolean> + ^ ClearFilterAutomatically ifNil: [ true ]! Item was added: + ----- Method: PluggableListMorph class>>filterableLists (in category 'preferences') ----- + filterableLists + <preference: 'Filterable Lists' + category: 'scrolling' + description: 'When true, using the keyboard on a list will filter it rather than scroll. Pressing enter or backspace restores all items to the list.' + type: #Boolean> + ^ FilterableLists ifNil: [ true ]! Item was added: + ----- Method: PluggableListMorph class>>filterableLists: (in category 'preferences') ----- + filterableLists: aBoolean + "When true, using the keyboard on a list will filter it rather than scroll. Pressing enter or backspace restores all items to the list." + FilterableLists := aBoolean! Item was changed: ----- Method: PluggableListMorph>>basicKeyPressed: (in category 'model access') ----- basicKeyPressed: aChar - | milliseconds slowKeyStroke listSize newSelectionIndex oldSelectionIndex startIndex | oldSelectionIndex := newSelectionIndex := self getCurrentSelectionIndex. listSize := self getListSize. milliseconds := Time millisecondClockValue. + slowKeyStroke := (Time + milliseconds: milliseconds + since: lastKeystrokeTime) > (self class filterableLists ifTrue: [500] ifFalse: [ 300 ]). - slowKeyStroke := (Time milliseconds: milliseconds since: lastKeystrokeTime) > 300. lastKeystrokeTime := milliseconds. slowKeyStroke + ifTrue: + [ self class filterableLists ifTrue: [ self hasFilter ifFalse: [ priorSelection := self modelIndexFor: self selectionIndex] ]. + "forget previous keystrokes and search in following elements" - ifTrue: ["forget previous keystrokes and search in following elements" lastKeystrokes := aChar asLowercase asString. + newSelectionIndex := newSelectionIndex \\ listSize + 1. + self class filterableLists ifTrue: [ list := self getFullList ] ] + ifFalse: [ "append quick keystrokes but don't move selection if it still matches" - newSelectionIndex := newSelectionIndex \\ listSize + 1 ] - ifFalse: ["append quick keystrokes but don't move selection if it still matches" lastKeystrokes := lastKeystrokes , aChar asLowercase asString. newSelectionIndex := newSelectionIndex max: 1 ]. "No change if model is locked" + model okToChange ifFalse: [ ^ self ]. + self class filterableLists + ifTrue: + [ self + filterList ; + updateList. + newSelectionIndex := self modelIndexFor: 1 ] + ifFalse: + [ startIndex := newSelectionIndex. + listSize := self getListSize. + [ (self getListItem: newSelectionIndex) asString withBlanksTrimmed asLowercase beginsWith: lastKeystrokes ] whileFalse: + [ (newSelectionIndex := newSelectionIndex \\ listSize + 1) = startIndex ifTrue: [ ^ self flash"Not in list." ] ]. + newSelectionIndex = oldSelectionIndex ifTrue: [ ^ self flash ] ]. + (self hasFilter and: [(self getCurrentSelectionIndex = newSelectionIndex) not]) ifTrue: + [self changeModelSelection: newSelectionIndex]! - model okToChange ifFalse: [ ^self ]. - "Get rid of blanks and style used in some lists" - startIndex := newSelectionIndex. - [ - (self getListItem: newSelectionIndex) asString - withBlanksTrimmed asLowercase beginsWith: lastKeystrokes ] - whileFalse: [ - (newSelectionIndex := newSelectionIndex \\ listSize + 1) = startIndex ifTrue: [ - ^self flash. "Not in list." ] ]. - newSelectionIndex = oldSelectionIndex ifTrue: [ ^self flash ]. "Same selection." - ^self changeModelSelection: newSelectionIndex! Item was added: + ----- Method: PluggableListMorph>>filterList (in category 'filtering') ----- + filterList + self hasFilter + ifTrue: + [ | frontMatching substringMatching newList | + self indicateFiltered. + frontMatching := OrderedCollection new. + substringMatching := OrderedCollection new. + list withIndexDo: + [ : each : n | | foundPos | + foundPos := each asString + findString: lastKeystrokes + startingAt: 1 + caseSensitive: false. + foundPos = 1 + ifTrue: [ frontMatching add: each ] + ifFalse: + [ foundPos = 0 ifFalse: [ substringMatching add: each ] ] ]. + newList := frontMatching , substringMatching. + newList + ifEmpty: + [ lastKeystrokes := lastKeystrokes allButLast: 1. + self + flash ; + filterList ] + ifNotEmpty: [ list := newList ] ] + ifFalse: [ self indicateUnfiltered ]! Item was added: + ----- Method: PluggableListMorph>>getFullList (in category 'model access') ----- + getFullList + "The full, unfiltered list." + ^ model perform: getListSelector! Item was changed: ----- Method: PluggableListMorph>>getList (in category 'model access') ----- getList "Answer the list to be displayed. Caches the returned list in the 'list' ivar" + getListSelector == nil ifTrue: [ ^ Array empty ]. + list := self getFullList. + self class filterableLists ifTrue: [ self filterList ]. - getListSelector == nil ifTrue: [ ^ #() ]. - list := model perform: getListSelector. ^ list ifNil: [ Array empty ]! Item was added: + ----- Method: PluggableListMorph>>hasFilter (in category 'filtering') ----- + hasFilter + ^ lastKeystrokes isEmptyOrNil not! Item was added: + ----- Method: PluggableListMorph>>indicateFiltered (in category 'filtering') ----- + indicateFiltered + self color: Color red muchLighter muchLighter! Item was added: + ----- Method: PluggableListMorph>>indicateUnfiltered (in category 'filtering') ----- + indicateUnfiltered + self color: Color white! Item was changed: ----- Method: PluggableListMorph>>keyboardFocusChange: (in category 'event handling') ----- + keyboardFocusChange: aBoolean - keyboardFocusChange: aBoolean "The message is sent to a morph when its keyboard focus changes. The given argument indicates that the receiver is gaining (versus losing) the keyboard focus. In this case, all we need to do is to redraw border feedback" + aBoolean ifFalse: + [ self class clearFilterAutomatically ifTrue: + [ self hasFilter ifTrue: + [ self + removeFilter ; + updateList ] ] ]. + (self innerBounds areasOutside: (self innerBounds insetBy: 1)) do: + [ : rect | self invalidRect: rect ]! - - (self innerBounds areasOutside: (self innerBounds insetBy: 1)) - do: [ :rect | self invalidRect: rect ]! Item was added: + ----- Method: PluggableListMorph>>modelIndexFor: (in category 'selection') ----- + modelIndexFor: selectionIndex + "The model does not know anything about the receiver's filtering, so if I am filtered, we must determine the correct index by scanning the full list in the model." + ^ (selectionIndex > 0 and: [ self hasFilter ]) + ifTrue: + [ list + ifEmpty: [ 0 ] + ifNotEmpty: [ self getFullList indexOf: (self getListItem: selectionIndex) ] ] + ifFalse: [ selectionIndex ]! Item was changed: ----- Method: PluggableListMorph>>mouseUp: (in category 'events') ----- mouseUp: event "The mouse came up within the list; take appropriate action" | row | row := self rowAtLocation: event position. "aMorph ifNotNil: [aMorph highlightForMouseDown: false]." model okToChange ifFalse: [^ self]. "No change if model is locked" row = self selectionIndex ifTrue: [(autoDeselect ifNil: [true]) ifTrue:[row = 0 ifFalse: [self changeModelSelection: 0] ]] + ifFalse: [self changeModelSelection: (self modelIndexFor: row)]. - ifFalse: [self changeModelSelection: row]. Cursor normal show! Item was added: + ----- Method: PluggableListMorph>>removeFilter (in category 'model access') ----- + removeFilter + lastKeystrokes := String empty. + list := nil! Item was changed: ----- Method: PluggableListMorph>>scrollSelectionIntoView (in category 'selection') ----- scrollSelectionIntoView "make sure that the current selection is visible" | row | + row := self uiIndexFor: self getCurrentSelectionIndex. - row := self getCurrentSelectionIndex. row = 0 ifTrue: [ ^ self ]. self scrollToShow: (self listMorph drawBoundsForRow: row)! Item was changed: ----- Method: PluggableListMorph>>selectedMorph: (in category 'selection') ----- selectedMorph: aMorph "this shouldn't be used any longer" + self isThisEverCalled . - "self isThisEverCalled ." - - Beeper beep. true ifTrue: [^self]! Item was changed: ----- Method: PluggableListMorph>>setSelectedMorph: (in category 'selection') ----- + setSelectedMorph: aMorph + self changeModelSelection: (self modelIndexFor: (scroller submorphs indexOf: aMorph))! - setSelectedMorph: aMorph - self changeModelSelection: (scroller submorphs indexOf: aMorph)! Item was changed: ----- Method: PluggableListMorph>>specialKeyPressed: (in category 'model access') ----- specialKeyPressed: asciiValue "A special key with the given ascii-value was pressed; dispatch it" - | oldSelection nextSelection max howManyItemsShowing | + (#(8 13) includes: asciiValue) ifTrue: + [ "backspace key - clear the filter, restore the list with the selection" + self removeFilter. + priorSelection ifNotNil: + [ | prior | + prior := priorSelection. + priorSelection := self getCurrentSelectionIndex. + asciiValue = 8 ifTrue: [ self changeModelSelection: prior ] ]. + ^ self updateList ]. asciiValue = 27 ifTrue: [" escape key" ^ ActiveEvent shiftPressed ifTrue: [ActiveWorld putUpWorldMenuFromEscapeKey] ifFalse: [self yellowButtonActivity: false]]. max := self maximumSelection. max > 0 ifFalse: [^ self]. + nextSelection := oldSelection := self selectionIndex. - nextSelection := oldSelection := self getCurrentSelectionIndex. asciiValue = 31 ifTrue: [" down arrow" nextSelection := oldSelection + 1. nextSelection > max ifTrue: [nextSelection := 1]]. asciiValue = 30 ifTrue: [" up arrow" nextSelection := oldSelection - 1. nextSelection < 1 ifTrue: [nextSelection := max]]. asciiValue = 1 ifTrue: [" home" nextSelection := 1]. asciiValue = 4 ifTrue: [" end" nextSelection := max]. howManyItemsShowing := self numSelectionsInView. asciiValue = 11 ifTrue: [" page up" nextSelection := 1 max: oldSelection - howManyItemsShowing]. asciiValue = 12 ifTrue: [" page down" nextSelection := oldSelection + howManyItemsShowing min: max]. model okToChange ifFalse: [^ self]. "No change if model is locked" oldSelection = nextSelection ifTrue: [^ self flash]. + ^ self changeModelSelection: (self modelIndexFor: nextSelection)! - ^ self changeModelSelection: nextSelection! Item was removed: - ----- Method: PluggableListMorph>>superDrawOn: (in category 'drawing') ----- - superDrawOn: aCanvas - super drawOn: aCanvas. - ! Item was added: + ----- Method: PluggableListMorph>>uiIndexFor: (in category 'selection') ----- + uiIndexFor: modelIndex + "The model does not know anything about the receiver's filtering. Answer the index in my (possibly filtered) list for modelIndex." + (modelIndex > 0 and: [ self hasFilter ]) + ifTrue: + [ | selectedItem | + selectedItem := self getFullList at: modelIndex. + (list ifNil: [ self getList ]) withIndexDo: + [ : eachMatchingItem : n | eachMatchingItem = selectedItem ifTrue: [ ^ n ] ]. + ^ 0 ] + ifFalse: [ ^ modelIndex ]! Item was changed: ----- Method: PluggableListMorph>>update: (in category 'updating') ----- update: aSymbol "Refer to the comment in View|update:." + aSymbol == getListSelector ifTrue: + [ self updateList. + ^ self ]. - - aSymbol == getListSelector ifTrue: - [self updateList. - ^ self]. aSymbol == getIndexSelector ifTrue: + [ | uiIndex modelIndex | + uiIndex := self uiIndexFor: (modelIndex := self getCurrentSelectionIndex). + self selectionIndex: + (uiIndex = 0 + ifTrue: + [ "The filter is preventing us from selecting the item we want - remove it." + (list notNil and: [list size > 0]) ifTrue: [ self removeFilter ]. + modelIndex ] + ifFalse: [ uiIndex ]). + ^ self ]! - [self selectionIndex: self getCurrentSelectionIndex. - ^ self]. - ! Item was changed: ----- Method: PluggableListMorph>>updateList (in category 'updating') ----- updateList | index | "the list has changed -- update from the model" self listMorph listChanged. self setScrollDeltas. scrollBar setValue: 0.0. index := self getCurrentSelectionIndex. self resetPotentialDropRow. + self selectionIndex: (self uiIndexFor: index). - self selectionIndex: index. ! Item was changed: ----- Method: PluggableListMorph>>verifyContents (in category 'updating') ----- verifyContents "Verify the contents of the receiver, reconstituting if necessary. Called whenever window is reactivated, to react to possible structural changes. Also called periodically in morphic if the smartUpdating preference is true" | newList existingSelection anIndex oldList | oldList := list ifNil: [ #() ]. newList := self getList. oldList = newList ifTrue: [ ^ self ]. existingSelection := self selectionIndex > 0 ifTrue: [ oldList at: self selectionIndex ] ifFalse: [ nil ]. self updateList. + (existingSelection notNil and: [(anIndex := self getFullList indexOf: existingSelection asStringOrText ifAbsent: [nil]) notNil]) - (existingSelection notNil and: [(anIndex := list indexOf: existingSelection asStringOrText ifAbsent: [nil]) notNil]) ifTrue: [model noteSelectionIndex: anIndex for: getListSelector. self selectionIndex: anIndex] ifFalse: [self changeModelSelection: 0]! Item was changed: ----- Method: PluggableListMorphOfMany>>mouseDown: (in category 'event handling') ----- mouseDown: event | oldIndex oldVal row | event yellowButtonPressed ifTrue: [^ self yellowButtonActivity: event shiftPressed]. row := self rowAtLocation: event position. row = 0 ifTrue: [^super mouseDown: event]. model okToChange ifFalse: [^ self]. "No change if model is locked" "Set meaning for subsequent dragging of selection" dragOnOrOff := (self listSelectionAt: row) not. oldIndex := self getCurrentSelectionIndex. oldIndex ~= 0 ifTrue: [oldVal := self listSelectionAt: oldIndex]. "Set or clear new primary selection (listIndex)" dragOnOrOff + ifTrue: [self changeModelSelection: (self modelIndexFor: row)] - ifTrue: [self changeModelSelection: row] ifFalse: [self changeModelSelection: 0]. "Need to restore the old one, due to how model works, and set new one." oldIndex ~= 0 ifTrue: [self listSelectionAt: oldIndex put: oldVal]. self listSelectionAt: row put: dragOnOrOff. "event hand releaseMouseFocus: aMorph." "aMorph changed"! Item was changed: ----- Method: PluggableListMorphOfMany>>mouseMove: (in category 'event handling') ----- mouseMove: event "The mouse has moved, as characterized by the event provided. Adjust the scrollbar, and alter the selection as appropriate" | oldIndex oldVal row | event position y < self top ifTrue: [scrollBar scrollUp: 1. row := self rowAtLocation: scroller topLeft + (1 @ 1)] ifFalse: [row := event position y > self bottom ifTrue: [scrollBar scrollDown: 1. self rowAtLocation: scroller bottomLeft + (1 @ -1)] ifFalse: [ self rowAtLocation: event position]]. row = 0 ifTrue: [^super mouseDown: event]. model okToChange ifFalse: [^self]. "No change if model is locked" dragOnOrOff ifNil: ["Was not set at mouse down, which means the mouse must have gone down in an area where there was no list item" dragOnOrOff := (self listSelectionAt: row) not]. "Set meaning for subsequent dragging of selection" oldIndex := self getCurrentSelectionIndex. oldIndex ~= 0 ifTrue: [oldVal := self listSelectionAt: oldIndex]. "Set or clear new primary selection (listIndex)" dragOnOrOff + ifTrue: [self changeModelSelection: (self modelIndexFor: row)] - ifTrue: [self changeModelSelection: row] ifFalse: [self changeModelSelection: 0]. "Need to restore the old one, due to how model works, and set new one." oldIndex ~= 0 ifTrue: [self listSelectionAt: oldIndex put: oldVal]. self listSelectionAt: row put: dragOnOrOff. row changed!
1
0
0
0
The Trunk: Morphic-cmm.585.mcz
by commits@source.squeak.org
08 Nov '11
08 Nov '11
Chris Muller uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-cmm.585.mcz
==================== Summary ==================== Name: Morphic-cmm.585 Author: cmm Time: 18 October 2011, 8:59:46.678 pm UUID: 96995b99-2105-4626-8c97-3ad777abf75d Ancestors: Morphic-cmm.584 - Added 'Filterable Lists Clear Automatically' preference. When using the Filterable Lists option, if this option is also selected, then the filter will be cleared as soon as the list loses keyboard focus. =============== Diff against Morphic-Richo.583 =============== Item was changed: ScrollPane subclass: #PluggableListMorph + instanceVariableNames: 'list getListSelector getListSizeSelector getListElementSelector getIndexSelector setIndexSelector keystrokeActionSelector autoDeselect lastKeystrokeTime lastKeystrokes lastClickTime doubleClickSelector handlesBasicKeys potentialDropRow listMorph hScrollRangeCache keystrokePreviewSelector priorSelection' + classVariableNames: 'ClearFilterAutomatically FilterableLists' - instanceVariableNames: 'list getListSelector getListSizeSelector getListElementSelector getIndexSelector setIndexSelector keystrokeActionSelector autoDeselect lastKeystrokeTime lastKeystrokes lastClickTime doubleClickSelector handlesBasicKeys potentialDropRow listMorph hScrollRangeCache keystrokePreviewSelector' - classVariableNames: '' poolDictionaries: '' category: 'Morphic-Pluggable Widgets'! + !PluggableListMorph commentStamp: 'cmm 8/21/2011 23:37' prior: 0! + When a PluggableListMorph is in focus, type in a letter (or several letters quickly) to go to the next item that begins with that letter (if FilterableLists is false). - !PluggableListMorph commentStamp: '<historical>' prior: 0! - ... - When a PluggableListMorph is in focus, type in a letter (or several - letters quickly) to go to the next item that begins with that letter. Special keys (up, down, home, etc.) are also supported.! Item was added: + ----- Method: PluggableListMorph class>>clearFilterAutomatically (in category 'preferences') ----- + clearFilterAutomatically + <preference: 'Filterable Lists Clear Automatically' + category: 'scrolling' + description: 'When using the Filterable Lists option, if this option is also selected, then the filter will be cleared as soon as the list loses keyboard focus.' + type: #Boolean> + ^ ClearFilterAutomatically ifNil: [ true ]! Item was added: + ----- Method: PluggableListMorph class>>filterableLists (in category 'preferences') ----- + filterableLists + <preference: 'Filterable Lists' + category: 'scrolling' + description: 'When true, using the keyboard on a list will filter it rather than scroll. Pressing enter or backspace restores all items to the list.' + type: #Boolean> + ^ FilterableLists ifNil: [ true ]! Item was added: + ----- Method: PluggableListMorph class>>filterableLists: (in category 'preferences') ----- + filterableLists: aBoolean + "When true, using the keyboard on a list will filter it rather than scroll. Pressing enter or backspace restores all items to the list." + FilterableLists := aBoolean! Item was changed: ----- Method: PluggableListMorph>>basicKeyPressed: (in category 'model access') ----- basicKeyPressed: aChar - | milliseconds slowKeyStroke listSize newSelectionIndex oldSelectionIndex startIndex | oldSelectionIndex := newSelectionIndex := self getCurrentSelectionIndex. listSize := self getListSize. milliseconds := Time millisecondClockValue. + slowKeyStroke := (Time + milliseconds: milliseconds + since: lastKeystrokeTime) > (self class filterableLists ifTrue: [500] ifFalse: [ 300 ]). - slowKeyStroke := (Time milliseconds: milliseconds since: lastKeystrokeTime) > 300. lastKeystrokeTime := milliseconds. slowKeyStroke + ifTrue: + [ self class filterableLists ifTrue: [ self hasFilter ifFalse: [ priorSelection := self modelIndexFor: self selectionIndex] ]. + "forget previous keystrokes and search in following elements" - ifTrue: ["forget previous keystrokes and search in following elements" lastKeystrokes := aChar asLowercase asString. + newSelectionIndex := newSelectionIndex \\ listSize + 1. + self class filterableLists ifTrue: [ list := self getFullList ] ] + ifFalse: [ "append quick keystrokes but don't move selection if it still matches" - newSelectionIndex := newSelectionIndex \\ listSize + 1 ] - ifFalse: ["append quick keystrokes but don't move selection if it still matches" lastKeystrokes := lastKeystrokes , aChar asLowercase asString. newSelectionIndex := newSelectionIndex max: 1 ]. "No change if model is locked" + model okToChange ifFalse: [ ^ self ]. + self class filterableLists + ifTrue: + [ self + filterList ; + updateList. + newSelectionIndex := self modelIndexFor: 1 ] + ifFalse: + [ startIndex := newSelectionIndex. + listSize := self getListSize. + [ (self getListItem: newSelectionIndex) asString withBlanksTrimmed asLowercase beginsWith: lastKeystrokes ] whileFalse: + [ (newSelectionIndex := newSelectionIndex \\ listSize + 1) = startIndex ifTrue: [ ^ self flash"Not in list." ] ]. + newSelectionIndex = oldSelectionIndex ifTrue: [ ^ self flash ] ]. + (self hasFilter and: [(self getCurrentSelectionIndex = newSelectionIndex) not]) ifTrue: + [self changeModelSelection: newSelectionIndex]! - model okToChange ifFalse: [ ^self ]. - "Get rid of blanks and style used in some lists" - startIndex := newSelectionIndex. - [ - (self getListItem: newSelectionIndex) asString - withBlanksTrimmed asLowercase beginsWith: lastKeystrokes ] - whileFalse: [ - (newSelectionIndex := newSelectionIndex \\ listSize + 1) = startIndex ifTrue: [ - ^self flash. "Not in list." ] ]. - newSelectionIndex = oldSelectionIndex ifTrue: [ ^self flash ]. "Same selection." - ^self changeModelSelection: newSelectionIndex! Item was added: + ----- Method: PluggableListMorph>>filterList (in category 'filtering') ----- + filterList + self hasFilter + ifTrue: + [ | frontMatching substringMatching newList | + self indicateFiltered. + frontMatching := OrderedCollection new. + substringMatching := OrderedCollection new. + list withIndexDo: + [ : each : n | | foundPos | + foundPos := each asString + findString: lastKeystrokes + startingAt: 1 + caseSensitive: false. + foundPos = 1 + ifTrue: [ frontMatching add: each ] + ifFalse: + [ foundPos = 0 ifFalse: [ substringMatching add: each ] ] ]. + newList := frontMatching , substringMatching. + newList + ifEmpty: + [ lastKeystrokes := lastKeystrokes allButLast: 1. + self + flash ; + filterList ] + ifNotEmpty: [ list := newList ] ] + ifFalse: [ self indicateUnfiltered ]! Item was added: + ----- Method: PluggableListMorph>>getFullList (in category 'model access') ----- + getFullList + "The full, unfiltered list." + ^ model perform: getListSelector! Item was changed: ----- Method: PluggableListMorph>>getList (in category 'model access') ----- getList "Answer the list to be displayed. Caches the returned list in the 'list' ivar" + getListSelector == nil ifTrue: [ ^ Array empty ]. + list := self getFullList. + self class filterableLists ifTrue: [ self filterList ]. - getListSelector == nil ifTrue: [ ^ #() ]. - list := model perform: getListSelector. ^ list ifNil: [ Array empty ]! Item was added: + ----- Method: PluggableListMorph>>hasFilter (in category 'filtering') ----- + hasFilter + ^ lastKeystrokes isEmptyOrNil not! Item was added: + ----- Method: PluggableListMorph>>indicateFiltered (in category 'filtering') ----- + indicateFiltered + self color: Color red muchLighter muchLighter! Item was added: + ----- Method: PluggableListMorph>>indicateUnfiltered (in category 'filtering') ----- + indicateUnfiltered + self color: Color white! Item was changed: ----- Method: PluggableListMorph>>keyboardFocusChange: (in category 'event handling') ----- + keyboardFocusChange: aBoolean - keyboardFocusChange: aBoolean "The message is sent to a morph when its keyboard focus changes. The given argument indicates that the receiver is gaining (versus losing) the keyboard focus. In this case, all we need to do is to redraw border feedback" + aBoolean ifFalse: + [ self class clearFilterAutomatically ifTrue: + [ self hasFilter ifTrue: + [ self + removeFilter ; + updateList ] ] ]. + (self innerBounds areasOutside: (self innerBounds insetBy: 1)) do: + [ : rect | self invalidRect: rect ]! - - (self innerBounds areasOutside: (self innerBounds insetBy: 1)) - do: [ :rect | self invalidRect: rect ]! Item was added: + ----- Method: PluggableListMorph>>modelIndexFor: (in category 'selection') ----- + modelIndexFor: selectionIndex + "The model does not know anything about the receiver's filtering, so if I am filtered, we must determine the correct index by scanning the full list in the model." + ^ (selectionIndex > 0 and: [ self hasFilter ]) + ifTrue: + [ list + ifEmpty: [ 0 ] + ifNotEmpty: [ self getFullList indexOf: (self getListItem: selectionIndex) ] ] + ifFalse: [ selectionIndex ]! Item was changed: ----- Method: PluggableListMorph>>mouseUp: (in category 'events') ----- mouseUp: event "The mouse came up within the list; take appropriate action" | row | row := self rowAtLocation: event position. "aMorph ifNotNil: [aMorph highlightForMouseDown: false]." model okToChange ifFalse: [^ self]. "No change if model is locked" row = self selectionIndex ifTrue: [(autoDeselect ifNil: [true]) ifTrue:[row = 0 ifFalse: [self changeModelSelection: 0] ]] + ifFalse: [self changeModelSelection: (self modelIndexFor: row)]. - ifFalse: [self changeModelSelection: row]. Cursor normal show! Item was added: + ----- Method: PluggableListMorph>>removeFilter (in category 'model access') ----- + removeFilter + lastKeystrokes := String empty. + list := nil! Item was changed: ----- Method: PluggableListMorph>>scrollSelectionIntoView (in category 'selection') ----- scrollSelectionIntoView "make sure that the current selection is visible" | row | + row := self uiIndexFor: self getCurrentSelectionIndex. - row := self getCurrentSelectionIndex. row = 0 ifTrue: [ ^ self ]. self scrollToShow: (self listMorph drawBoundsForRow: row)! Item was changed: ----- Method: PluggableListMorph>>selectedMorph: (in category 'selection') ----- selectedMorph: aMorph "this shouldn't be used any longer" + self isThisEverCalled . - "self isThisEverCalled ." - - Beeper beep. true ifTrue: [^self]! Item was changed: ----- Method: PluggableListMorph>>setSelectedMorph: (in category 'selection') ----- + setSelectedMorph: aMorph + self changeModelSelection: (self modelIndexFor: (scroller submorphs indexOf: aMorph))! - setSelectedMorph: aMorph - self changeModelSelection: (scroller submorphs indexOf: aMorph)! Item was changed: ----- Method: PluggableListMorph>>specialKeyPressed: (in category 'model access') ----- specialKeyPressed: asciiValue "A special key with the given ascii-value was pressed; dispatch it" - | oldSelection nextSelection max howManyItemsShowing | + (#(8 13) includes: asciiValue) ifTrue: + [ "backspace key - clear the filter, restore the list with the selection" + self removeFilter. + priorSelection ifNotNil: + [ | prior | + prior := priorSelection. + priorSelection := self getCurrentSelectionIndex. + asciiValue = 8 ifTrue: [ self changeModelSelection: prior ] ]. + ^ self updateList ]. asciiValue = 27 ifTrue: [" escape key" ^ ActiveEvent shiftPressed ifTrue: [ActiveWorld putUpWorldMenuFromEscapeKey] ifFalse: [self yellowButtonActivity: false]]. max := self maximumSelection. max > 0 ifFalse: [^ self]. + nextSelection := oldSelection := self selectionIndex. - nextSelection := oldSelection := self getCurrentSelectionIndex. asciiValue = 31 ifTrue: [" down arrow" nextSelection := oldSelection + 1. nextSelection > max ifTrue: [nextSelection := 1]]. asciiValue = 30 ifTrue: [" up arrow" nextSelection := oldSelection - 1. nextSelection < 1 ifTrue: [nextSelection := max]]. asciiValue = 1 ifTrue: [" home" nextSelection := 1]. asciiValue = 4 ifTrue: [" end" nextSelection := max]. howManyItemsShowing := self numSelectionsInView. asciiValue = 11 ifTrue: [" page up" nextSelection := 1 max: oldSelection - howManyItemsShowing]. asciiValue = 12 ifTrue: [" page down" nextSelection := oldSelection + howManyItemsShowing min: max]. model okToChange ifFalse: [^ self]. "No change if model is locked" oldSelection = nextSelection ifTrue: [^ self flash]. + ^ self changeModelSelection: (self modelIndexFor: nextSelection)! - ^ self changeModelSelection: nextSelection! Item was removed: - ----- Method: PluggableListMorph>>superDrawOn: (in category 'drawing') ----- - superDrawOn: aCanvas - super drawOn: aCanvas. - ! Item was added: + ----- Method: PluggableListMorph>>uiIndexFor: (in category 'selection') ----- + uiIndexFor: modelIndex + "The model does not know anything about the receiver's filtering. Answer the index in my (possibly filtered) list for modelIndex." + (modelIndex > 0 and: [ self hasFilter ]) + ifTrue: + [ | selectedItem | + selectedItem := self getFullList at: modelIndex. + (list ifNil: [ self getList ]) withIndexDo: + [ : eachMatchingItem : n | eachMatchingItem = selectedItem ifTrue: [ ^ n ] ]. + ^ 0 ] + ifFalse: [ ^ modelIndex ]! Item was changed: ----- Method: PluggableListMorph>>update: (in category 'updating') ----- update: aSymbol "Refer to the comment in View|update:." + aSymbol == getListSelector ifTrue: + [ self updateList. + ^ self ]. - - aSymbol == getListSelector ifTrue: - [self updateList. - ^ self]. aSymbol == getIndexSelector ifTrue: + [ | uiIndex modelIndex | + uiIndex := self uiIndexFor: (modelIndex := self getCurrentSelectionIndex). + self selectionIndex: + (uiIndex = 0 + ifTrue: + [ "The filter is preventing us from selecting the item we want - remove it." + (list notNil and: [list size > 0]) ifTrue: [ self removeFilter ]. + modelIndex ] + ifFalse: [ uiIndex ]). + ^ self ]! - [self selectionIndex: self getCurrentSelectionIndex. - ^ self]. - ! Item was changed: ----- Method: PluggableListMorph>>updateList (in category 'updating') ----- updateList | index | "the list has changed -- update from the model" self listMorph listChanged. self setScrollDeltas. scrollBar setValue: 0.0. index := self getCurrentSelectionIndex. self resetPotentialDropRow. + self selectionIndex: (self uiIndexFor: index). - self selectionIndex: index. ! Item was changed: ----- Method: PluggableListMorph>>verifyContents (in category 'updating') ----- verifyContents "Verify the contents of the receiver, reconstituting if necessary. Called whenever window is reactivated, to react to possible structural changes. Also called periodically in morphic if the smartUpdating preference is true" | newList existingSelection anIndex oldList | oldList := list ifNil: [ #() ]. newList := self getList. oldList = newList ifTrue: [ ^ self ]. existingSelection := self selectionIndex > 0 ifTrue: [ oldList at: self selectionIndex ] ifFalse: [ nil ]. self updateList. + (existingSelection notNil and: [(anIndex := self getFullList indexOf: existingSelection asStringOrText ifAbsent: [nil]) notNil]) - (existingSelection notNil and: [(anIndex := list indexOf: existingSelection asStringOrText ifAbsent: [nil]) notNil]) ifTrue: [model noteSelectionIndex: anIndex for: getListSelector. self selectionIndex: anIndex] ifFalse: [self changeModelSelection: 0]! Item was changed: ----- Method: PluggableListMorphOfMany>>mouseDown: (in category 'event handling') ----- mouseDown: event | oldIndex oldVal row | event yellowButtonPressed ifTrue: [^ self yellowButtonActivity: event shiftPressed]. row := self rowAtLocation: event position. row = 0 ifTrue: [^super mouseDown: event]. model okToChange ifFalse: [^ self]. "No change if model is locked" "Set meaning for subsequent dragging of selection" dragOnOrOff := (self listSelectionAt: row) not. oldIndex := self getCurrentSelectionIndex. oldIndex ~= 0 ifTrue: [oldVal := self listSelectionAt: oldIndex]. "Set or clear new primary selection (listIndex)" dragOnOrOff + ifTrue: [self changeModelSelection: (self modelIndexFor: row)] - ifTrue: [self changeModelSelection: row] ifFalse: [self changeModelSelection: 0]. "Need to restore the old one, due to how model works, and set new one." oldIndex ~= 0 ifTrue: [self listSelectionAt: oldIndex put: oldVal]. self listSelectionAt: row put: dragOnOrOff. "event hand releaseMouseFocus: aMorph." "aMorph changed"! Item was changed: ----- Method: PluggableListMorphOfMany>>mouseMove: (in category 'event handling') ----- mouseMove: event "The mouse has moved, as characterized by the event provided. Adjust the scrollbar, and alter the selection as appropriate" | oldIndex oldVal row | event position y < self top ifTrue: [scrollBar scrollUp: 1. row := self rowAtLocation: scroller topLeft + (1 @ 1)] ifFalse: [row := event position y > self bottom ifTrue: [scrollBar scrollDown: 1. self rowAtLocation: scroller bottomLeft + (1 @ -1)] ifFalse: [ self rowAtLocation: event position]]. row = 0 ifTrue: [^super mouseDown: event]. model okToChange ifFalse: [^self]. "No change if model is locked" dragOnOrOff ifNil: ["Was not set at mouse down, which means the mouse must have gone down in an area where there was no list item" dragOnOrOff := (self listSelectionAt: row) not]. "Set meaning for subsequent dragging of selection" oldIndex := self getCurrentSelectionIndex. oldIndex ~= 0 ifTrue: [oldVal := self listSelectionAt: oldIndex]. "Set or clear new primary selection (listIndex)" dragOnOrOff + ifTrue: [self changeModelSelection: (self modelIndexFor: row)] - ifTrue: [self changeModelSelection: row] ifFalse: [self changeModelSelection: 0]. "Need to restore the old one, due to how model works, and set new one." oldIndex ~= 0 ifTrue: [self listSelectionAt: oldIndex put: oldVal]. self listSelectionAt: row put: dragOnOrOff. row changed!
1
0
0
0
The Trunk: Morphic-cmm.585.mcz
by commits@source.squeak.org
08 Nov '11
08 Nov '11
Chris Muller uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-cmm.585.mcz
==================== Summary ==================== Name: Morphic-cmm.585 Author: cmm Time: 18 October 2011, 8:59:46.678 pm UUID: 96995b99-2105-4626-8c97-3ad777abf75d Ancestors: Morphic-cmm.584 - Added 'Filterable Lists Clear Automatically' preference. When using the Filterable Lists option, if this option is also selected, then the filter will be cleared as soon as the list loses keyboard focus. =============== Diff against Morphic-Richo.583 =============== Item was changed: ScrollPane subclass: #PluggableListMorph + instanceVariableNames: 'list getListSelector getListSizeSelector getListElementSelector getIndexSelector setIndexSelector keystrokeActionSelector autoDeselect lastKeystrokeTime lastKeystrokes lastClickTime doubleClickSelector handlesBasicKeys potentialDropRow listMorph hScrollRangeCache keystrokePreviewSelector priorSelection' + classVariableNames: 'ClearFilterAutomatically FilterableLists' - instanceVariableNames: 'list getListSelector getListSizeSelector getListElementSelector getIndexSelector setIndexSelector keystrokeActionSelector autoDeselect lastKeystrokeTime lastKeystrokes lastClickTime doubleClickSelector handlesBasicKeys potentialDropRow listMorph hScrollRangeCache keystrokePreviewSelector' - classVariableNames: '' poolDictionaries: '' category: 'Morphic-Pluggable Widgets'! + !PluggableListMorph commentStamp: 'cmm 8/21/2011 23:37' prior: 0! + When a PluggableListMorph is in focus, type in a letter (or several letters quickly) to go to the next item that begins with that letter (if FilterableLists is false). - !PluggableListMorph commentStamp: '<historical>' prior: 0! - ... - When a PluggableListMorph is in focus, type in a letter (or several - letters quickly) to go to the next item that begins with that letter. Special keys (up, down, home, etc.) are also supported.! Item was added: + ----- Method: PluggableListMorph class>>clearFilterAutomatically (in category 'preferences') ----- + clearFilterAutomatically + <preference: 'Filterable Lists Clear Automatically' + category: 'scrolling' + description: 'When using the Filterable Lists option, if this option is also selected, then the filter will be cleared as soon as the list loses keyboard focus.' + type: #Boolean> + ^ ClearFilterAutomatically ifNil: [ true ]! Item was added: + ----- Method: PluggableListMorph class>>filterableLists (in category 'preferences') ----- + filterableLists + <preference: 'Filterable Lists' + category: 'scrolling' + description: 'When true, using the keyboard on a list will filter it rather than scroll. Pressing enter or backspace restores all items to the list.' + type: #Boolean> + ^ FilterableLists ifNil: [ true ]! Item was added: + ----- Method: PluggableListMorph class>>filterableLists: (in category 'preferences') ----- + filterableLists: aBoolean + "When true, using the keyboard on a list will filter it rather than scroll. Pressing enter or backspace restores all items to the list." + FilterableLists := aBoolean! Item was changed: ----- Method: PluggableListMorph>>basicKeyPressed: (in category 'model access') ----- basicKeyPressed: aChar - | milliseconds slowKeyStroke listSize newSelectionIndex oldSelectionIndex startIndex | oldSelectionIndex := newSelectionIndex := self getCurrentSelectionIndex. listSize := self getListSize. milliseconds := Time millisecondClockValue. + slowKeyStroke := (Time + milliseconds: milliseconds + since: lastKeystrokeTime) > (self class filterableLists ifTrue: [500] ifFalse: [ 300 ]). - slowKeyStroke := (Time milliseconds: milliseconds since: lastKeystrokeTime) > 300. lastKeystrokeTime := milliseconds. slowKeyStroke + ifTrue: + [ self class filterableLists ifTrue: [ self hasFilter ifFalse: [ priorSelection := self modelIndexFor: self selectionIndex] ]. + "forget previous keystrokes and search in following elements" - ifTrue: ["forget previous keystrokes and search in following elements" lastKeystrokes := aChar asLowercase asString. + newSelectionIndex := newSelectionIndex \\ listSize + 1. + self class filterableLists ifTrue: [ list := self getFullList ] ] + ifFalse: [ "append quick keystrokes but don't move selection if it still matches" - newSelectionIndex := newSelectionIndex \\ listSize + 1 ] - ifFalse: ["append quick keystrokes but don't move selection if it still matches" lastKeystrokes := lastKeystrokes , aChar asLowercase asString. newSelectionIndex := newSelectionIndex max: 1 ]. "No change if model is locked" + model okToChange ifFalse: [ ^ self ]. + self class filterableLists + ifTrue: + [ self + filterList ; + updateList. + newSelectionIndex := self modelIndexFor: 1 ] + ifFalse: + [ startIndex := newSelectionIndex. + listSize := self getListSize. + [ (self getListItem: newSelectionIndex) asString withBlanksTrimmed asLowercase beginsWith: lastKeystrokes ] whileFalse: + [ (newSelectionIndex := newSelectionIndex \\ listSize + 1) = startIndex ifTrue: [ ^ self flash"Not in list." ] ]. + newSelectionIndex = oldSelectionIndex ifTrue: [ ^ self flash ] ]. + (self hasFilter and: [(self getCurrentSelectionIndex = newSelectionIndex) not]) ifTrue: + [self changeModelSelection: newSelectionIndex]! - model okToChange ifFalse: [ ^self ]. - "Get rid of blanks and style used in some lists" - startIndex := newSelectionIndex. - [ - (self getListItem: newSelectionIndex) asString - withBlanksTrimmed asLowercase beginsWith: lastKeystrokes ] - whileFalse: [ - (newSelectionIndex := newSelectionIndex \\ listSize + 1) = startIndex ifTrue: [ - ^self flash. "Not in list." ] ]. - newSelectionIndex = oldSelectionIndex ifTrue: [ ^self flash ]. "Same selection." - ^self changeModelSelection: newSelectionIndex! Item was added: + ----- Method: PluggableListMorph>>filterList (in category 'filtering') ----- + filterList + self hasFilter + ifTrue: + [ | frontMatching substringMatching newList | + self indicateFiltered. + frontMatching := OrderedCollection new. + substringMatching := OrderedCollection new. + list withIndexDo: + [ : each : n | | foundPos | + foundPos := each asString + findString: lastKeystrokes + startingAt: 1 + caseSensitive: false. + foundPos = 1 + ifTrue: [ frontMatching add: each ] + ifFalse: + [ foundPos = 0 ifFalse: [ substringMatching add: each ] ] ]. + newList := frontMatching , substringMatching. + newList + ifEmpty: + [ lastKeystrokes := lastKeystrokes allButLast: 1. + self + flash ; + filterList ] + ifNotEmpty: [ list := newList ] ] + ifFalse: [ self indicateUnfiltered ]! Item was added: + ----- Method: PluggableListMorph>>getFullList (in category 'model access') ----- + getFullList + "The full, unfiltered list." + ^ model perform: getListSelector! Item was changed: ----- Method: PluggableListMorph>>getList (in category 'model access') ----- getList "Answer the list to be displayed. Caches the returned list in the 'list' ivar" + getListSelector == nil ifTrue: [ ^ Array empty ]. + list := self getFullList. + self class filterableLists ifTrue: [ self filterList ]. - getListSelector == nil ifTrue: [ ^ #() ]. - list := model perform: getListSelector. ^ list ifNil: [ Array empty ]! Item was added: + ----- Method: PluggableListMorph>>hasFilter (in category 'filtering') ----- + hasFilter + ^ lastKeystrokes isEmptyOrNil not! Item was added: + ----- Method: PluggableListMorph>>indicateFiltered (in category 'filtering') ----- + indicateFiltered + self color: Color red muchLighter muchLighter! Item was added: + ----- Method: PluggableListMorph>>indicateUnfiltered (in category 'filtering') ----- + indicateUnfiltered + self color: Color white! Item was changed: ----- Method: PluggableListMorph>>keyboardFocusChange: (in category 'event handling') ----- + keyboardFocusChange: aBoolean - keyboardFocusChange: aBoolean "The message is sent to a morph when its keyboard focus changes. The given argument indicates that the receiver is gaining (versus losing) the keyboard focus. In this case, all we need to do is to redraw border feedback" + aBoolean ifFalse: + [ self class clearFilterAutomatically ifTrue: + [ self hasFilter ifTrue: + [ self + removeFilter ; + updateList ] ] ]. + (self innerBounds areasOutside: (self innerBounds insetBy: 1)) do: + [ : rect | self invalidRect: rect ]! - - (self innerBounds areasOutside: (self innerBounds insetBy: 1)) - do: [ :rect | self invalidRect: rect ]! Item was added: + ----- Method: PluggableListMorph>>modelIndexFor: (in category 'selection') ----- + modelIndexFor: selectionIndex + "The model does not know anything about the receiver's filtering, so if I am filtered, we must determine the correct index by scanning the full list in the model." + ^ (selectionIndex > 0 and: [ self hasFilter ]) + ifTrue: + [ list + ifEmpty: [ 0 ] + ifNotEmpty: [ self getFullList indexOf: (self getListItem: selectionIndex) ] ] + ifFalse: [ selectionIndex ]! Item was changed: ----- Method: PluggableListMorph>>mouseUp: (in category 'events') ----- mouseUp: event "The mouse came up within the list; take appropriate action" | row | row := self rowAtLocation: event position. "aMorph ifNotNil: [aMorph highlightForMouseDown: false]." model okToChange ifFalse: [^ self]. "No change if model is locked" row = self selectionIndex ifTrue: [(autoDeselect ifNil: [true]) ifTrue:[row = 0 ifFalse: [self changeModelSelection: 0] ]] + ifFalse: [self changeModelSelection: (self modelIndexFor: row)]. - ifFalse: [self changeModelSelection: row]. Cursor normal show! Item was added: + ----- Method: PluggableListMorph>>removeFilter (in category 'model access') ----- + removeFilter + lastKeystrokes := String empty. + list := nil! Item was changed: ----- Method: PluggableListMorph>>scrollSelectionIntoView (in category 'selection') ----- scrollSelectionIntoView "make sure that the current selection is visible" | row | + row := self uiIndexFor: self getCurrentSelectionIndex. - row := self getCurrentSelectionIndex. row = 0 ifTrue: [ ^ self ]. self scrollToShow: (self listMorph drawBoundsForRow: row)! Item was changed: ----- Method: PluggableListMorph>>selectedMorph: (in category 'selection') ----- selectedMorph: aMorph "this shouldn't be used any longer" + self isThisEverCalled . - "self isThisEverCalled ." - - Beeper beep. true ifTrue: [^self]! Item was changed: ----- Method: PluggableListMorph>>setSelectedMorph: (in category 'selection') ----- + setSelectedMorph: aMorph + self changeModelSelection: (self modelIndexFor: (scroller submorphs indexOf: aMorph))! - setSelectedMorph: aMorph - self changeModelSelection: (scroller submorphs indexOf: aMorph)! Item was changed: ----- Method: PluggableListMorph>>specialKeyPressed: (in category 'model access') ----- specialKeyPressed: asciiValue "A special key with the given ascii-value was pressed; dispatch it" - | oldSelection nextSelection max howManyItemsShowing | + (#(8 13) includes: asciiValue) ifTrue: + [ "backspace key - clear the filter, restore the list with the selection" + self removeFilter. + priorSelection ifNotNil: + [ | prior | + prior := priorSelection. + priorSelection := self getCurrentSelectionIndex. + asciiValue = 8 ifTrue: [ self changeModelSelection: prior ] ]. + ^ self updateList ]. asciiValue = 27 ifTrue: [" escape key" ^ ActiveEvent shiftPressed ifTrue: [ActiveWorld putUpWorldMenuFromEscapeKey] ifFalse: [self yellowButtonActivity: false]]. max := self maximumSelection. max > 0 ifFalse: [^ self]. + nextSelection := oldSelection := self selectionIndex. - nextSelection := oldSelection := self getCurrentSelectionIndex. asciiValue = 31 ifTrue: [" down arrow" nextSelection := oldSelection + 1. nextSelection > max ifTrue: [nextSelection := 1]]. asciiValue = 30 ifTrue: [" up arrow" nextSelection := oldSelection - 1. nextSelection < 1 ifTrue: [nextSelection := max]]. asciiValue = 1 ifTrue: [" home" nextSelection := 1]. asciiValue = 4 ifTrue: [" end" nextSelection := max]. howManyItemsShowing := self numSelectionsInView. asciiValue = 11 ifTrue: [" page up" nextSelection := 1 max: oldSelection - howManyItemsShowing]. asciiValue = 12 ifTrue: [" page down" nextSelection := oldSelection + howManyItemsShowing min: max]. model okToChange ifFalse: [^ self]. "No change if model is locked" oldSelection = nextSelection ifTrue: [^ self flash]. + ^ self changeModelSelection: (self modelIndexFor: nextSelection)! - ^ self changeModelSelection: nextSelection! Item was removed: - ----- Method: PluggableListMorph>>superDrawOn: (in category 'drawing') ----- - superDrawOn: aCanvas - super drawOn: aCanvas. - ! Item was added: + ----- Method: PluggableListMorph>>uiIndexFor: (in category 'selection') ----- + uiIndexFor: modelIndex + "The model does not know anything about the receiver's filtering. Answer the index in my (possibly filtered) list for modelIndex." + (modelIndex > 0 and: [ self hasFilter ]) + ifTrue: + [ | selectedItem | + selectedItem := self getFullList at: modelIndex. + (list ifNil: [ self getList ]) withIndexDo: + [ : eachMatchingItem : n | eachMatchingItem = selectedItem ifTrue: [ ^ n ] ]. + ^ 0 ] + ifFalse: [ ^ modelIndex ]! Item was changed: ----- Method: PluggableListMorph>>update: (in category 'updating') ----- update: aSymbol "Refer to the comment in View|update:." + aSymbol == getListSelector ifTrue: + [ self updateList. + ^ self ]. - - aSymbol == getListSelector ifTrue: - [self updateList. - ^ self]. aSymbol == getIndexSelector ifTrue: + [ | uiIndex modelIndex | + uiIndex := self uiIndexFor: (modelIndex := self getCurrentSelectionIndex). + self selectionIndex: + (uiIndex = 0 + ifTrue: + [ "The filter is preventing us from selecting the item we want - remove it." + (list notNil and: [list size > 0]) ifTrue: [ self removeFilter ]. + modelIndex ] + ifFalse: [ uiIndex ]). + ^ self ]! - [self selectionIndex: self getCurrentSelectionIndex. - ^ self]. - ! Item was changed: ----- Method: PluggableListMorph>>updateList (in category 'updating') ----- updateList | index | "the list has changed -- update from the model" self listMorph listChanged. self setScrollDeltas. scrollBar setValue: 0.0. index := self getCurrentSelectionIndex. self resetPotentialDropRow. + self selectionIndex: (self uiIndexFor: index). - self selectionIndex: index. ! Item was changed: ----- Method: PluggableListMorph>>verifyContents (in category 'updating') ----- verifyContents "Verify the contents of the receiver, reconstituting if necessary. Called whenever window is reactivated, to react to possible structural changes. Also called periodically in morphic if the smartUpdating preference is true" | newList existingSelection anIndex oldList | oldList := list ifNil: [ #() ]. newList := self getList. oldList = newList ifTrue: [ ^ self ]. existingSelection := self selectionIndex > 0 ifTrue: [ oldList at: self selectionIndex ] ifFalse: [ nil ]. self updateList. + (existingSelection notNil and: [(anIndex := self getFullList indexOf: existingSelection asStringOrText ifAbsent: [nil]) notNil]) - (existingSelection notNil and: [(anIndex := list indexOf: existingSelection asStringOrText ifAbsent: [nil]) notNil]) ifTrue: [model noteSelectionIndex: anIndex for: getListSelector. self selectionIndex: anIndex] ifFalse: [self changeModelSelection: 0]! Item was changed: ----- Method: PluggableListMorphOfMany>>mouseDown: (in category 'event handling') ----- mouseDown: event | oldIndex oldVal row | event yellowButtonPressed ifTrue: [^ self yellowButtonActivity: event shiftPressed]. row := self rowAtLocation: event position. row = 0 ifTrue: [^super mouseDown: event]. model okToChange ifFalse: [^ self]. "No change if model is locked" "Set meaning for subsequent dragging of selection" dragOnOrOff := (self listSelectionAt: row) not. oldIndex := self getCurrentSelectionIndex. oldIndex ~= 0 ifTrue: [oldVal := self listSelectionAt: oldIndex]. "Set or clear new primary selection (listIndex)" dragOnOrOff + ifTrue: [self changeModelSelection: (self modelIndexFor: row)] - ifTrue: [self changeModelSelection: row] ifFalse: [self changeModelSelection: 0]. "Need to restore the old one, due to how model works, and set new one." oldIndex ~= 0 ifTrue: [self listSelectionAt: oldIndex put: oldVal]. self listSelectionAt: row put: dragOnOrOff. "event hand releaseMouseFocus: aMorph." "aMorph changed"! Item was changed: ----- Method: PluggableListMorphOfMany>>mouseMove: (in category 'event handling') ----- mouseMove: event "The mouse has moved, as characterized by the event provided. Adjust the scrollbar, and alter the selection as appropriate" | oldIndex oldVal row | event position y < self top ifTrue: [scrollBar scrollUp: 1. row := self rowAtLocation: scroller topLeft + (1 @ 1)] ifFalse: [row := event position y > self bottom ifTrue: [scrollBar scrollDown: 1. self rowAtLocation: scroller bottomLeft + (1 @ -1)] ifFalse: [ self rowAtLocation: event position]]. row = 0 ifTrue: [^super mouseDown: event]. model okToChange ifFalse: [^self]. "No change if model is locked" dragOnOrOff ifNil: ["Was not set at mouse down, which means the mouse must have gone down in an area where there was no list item" dragOnOrOff := (self listSelectionAt: row) not]. "Set meaning for subsequent dragging of selection" oldIndex := self getCurrentSelectionIndex. oldIndex ~= 0 ifTrue: [oldVal := self listSelectionAt: oldIndex]. "Set or clear new primary selection (listIndex)" dragOnOrOff + ifTrue: [self changeModelSelection: (self modelIndexFor: row)] - ifTrue: [self changeModelSelection: row] ifFalse: [self changeModelSelection: 0]. "Need to restore the old one, due to how model works, and set new one." oldIndex ~= 0 ifTrue: [self listSelectionAt: oldIndex put: oldVal]. self listSelectionAt: row put: dragOnOrOff. row changed!
1
0
0
0
The Trunk: ToolBuilder-Morphic-cmm.80.mcz
by commits@source.squeak.org
08 Nov '11
08 Nov '11
Chris Muller uploaded a new version of ToolBuilder-Morphic to project The Trunk:
http://source.squeak.org/trunk/ToolBuilder-Morphic-cmm.80.mcz
==================== Summary ==================== Name: ToolBuilder-Morphic-cmm.80 Author: cmm Time: 17 September 2011, 11:00:22.25 pm UUID: 9356e41c-aff9-40bb-898d-dbaab2405e22 Ancestors: ToolBuilder-Morphic-ul.79 Fix for dragging messages out of filtered PluggableListMorphs. =============== Diff against ToolBuilder-Morphic-ul.79 =============== Item was changed: ----- Method: PluggableListMorphPlus>>startDrag: (in category 'drag and drop') ----- startDrag: evt dragItemSelector ifNil:[^self]. evt hand hasSubmorphs ifTrue: [^ self]. [ | dragIndex draggedItem ddm | (self dragEnabled and: [model okToChange]) ifFalse: [^ self]. dragIndex := self rowAtLocation: evt position. dragIndex = 0 ifTrue:[^self]. + draggedItem := model perform: dragItemSelector with: (self modelIndexFor: dragIndex). - draggedItem := model perform: dragItemSelector with: dragIndex. draggedItem ifNil:[^self]. ddm := TransferMorph withPassenger: draggedItem from: self. ddm dragTransferType: #dragTransferPlus. evt hand grabMorph: ddm] ensure: [Cursor normal show. evt hand releaseMouseFocus: self]!
1
0
0
0
The Trunk: ToolBuilder-Morphic-cmm.80.mcz
by commits@source.squeak.org
08 Nov '11
08 Nov '11
Chris Muller uploaded a new version of ToolBuilder-Morphic to project The Trunk:
http://source.squeak.org/trunk/ToolBuilder-Morphic-cmm.80.mcz
==================== Summary ==================== Name: ToolBuilder-Morphic-cmm.80 Author: cmm Time: 17 September 2011, 11:00:22.25 pm UUID: 9356e41c-aff9-40bb-898d-dbaab2405e22 Ancestors: ToolBuilder-Morphic-ul.79 Fix for dragging messages out of filtered PluggableListMorphs. =============== Diff against ToolBuilder-Morphic-ul.79 =============== Item was changed: ----- Method: PluggableListMorphPlus>>startDrag: (in category 'drag and drop') ----- startDrag: evt dragItemSelector ifNil:[^self]. evt hand hasSubmorphs ifTrue: [^ self]. [ | dragIndex draggedItem ddm | (self dragEnabled and: [model okToChange]) ifFalse: [^ self]. dragIndex := self rowAtLocation: evt position. dragIndex = 0 ifTrue:[^self]. + draggedItem := model perform: dragItemSelector with: (self modelIndexFor: dragIndex). - draggedItem := model perform: dragItemSelector with: dragIndex. draggedItem ifNil:[^self]. ddm := TransferMorph withPassenger: draggedItem from: self. ddm dragTransferType: #dragTransferPlus. evt hand grabMorph: ddm] ensure: [Cursor normal show. evt hand releaseMouseFocus: self]!
1
0
0
0
The Trunk: ToolBuilder-Morphic-cmm.80.mcz
by commits@source.squeak.org
08 Nov '11
08 Nov '11
Chris Muller uploaded a new version of ToolBuilder-Morphic to project The Trunk:
http://source.squeak.org/trunk/ToolBuilder-Morphic-cmm.80.mcz
==================== Summary ==================== Name: ToolBuilder-Morphic-cmm.80 Author: cmm Time: 17 September 2011, 11:00:22.25 pm UUID: 9356e41c-aff9-40bb-898d-dbaab2405e22 Ancestors: ToolBuilder-Morphic-ul.79 Fix for dragging messages out of filtered PluggableListMorphs. =============== Diff against ToolBuilder-Morphic-ul.79 =============== Item was changed: ----- Method: PluggableListMorphPlus>>startDrag: (in category 'drag and drop') ----- startDrag: evt dragItemSelector ifNil:[^self]. evt hand hasSubmorphs ifTrue: [^ self]. [ | dragIndex draggedItem ddm | (self dragEnabled and: [model okToChange]) ifFalse: [^ self]. dragIndex := self rowAtLocation: evt position. dragIndex = 0 ifTrue:[^self]. + draggedItem := model perform: dragItemSelector with: (self modelIndexFor: dragIndex). - draggedItem := model perform: dragItemSelector with: dragIndex. draggedItem ifNil:[^self]. ddm := TransferMorph withPassenger: draggedItem from: self. ddm dragTransferType: #dragTransferPlus. evt hand grabMorph: ddm] ensure: [Cursor normal show. evt hand releaseMouseFocus: self]!
1
0
0
0
The Trunk: SMBase-gk.110.mcz
by commits@source.squeak.org
08 Nov '11
08 Nov '11
Chris Muller uploaded a new version of SMBase to project The Trunk:
http://source.squeak.org/trunk/SMBase-gk.110.mcz
==================== Summary ==================== Name: SMBase-gk.110 Author: gk Time: 12 April 2010, 1:00:20 am UUID: ce768c9a-89ba-4cd8-803d-21f3f84de496 Ancestors: SMBase-gk.109 Backed out changes to file handling, not compatible with 3.8. =============== Diff against SMBase-gk.109 =============== Item was changed: ----- Method: SMAccount>>newFile:block: (in category 'files') ----- newFile: fileName block: aBlock "Create a new file. Let <aBlock> fill the file with content by calling it with a stream." + | dir stream | - | dir | dir := self uploadsDirectory. + [(dir fileExists: fileName) ifTrue:[dir deleteFileNamed: fileName]. + stream := dir newFileNamed: fileName. + stream binary. + aBlock value: stream] ensure: [stream close]! - (dir fileExists: fileName) ifTrue:[dir deleteFileNamed: fileName]. - dir newFileNamed: fileName do: [:stream | - stream binary. - aBlock value: stream]! Item was changed: ----- Method: SMSqueakMap>>saveCheckpoint: (in category 'checkpoints') ----- saveCheckpoint: contentWithFilename "Save the map checkpoint to disk if it is not there already." + | file directory sz fname content | - | directory sz fname content | directory := self directory. sz := contentWithFilename size. fname := contentWithFilename last: sz - (contentWithFilename lastIndexOf: $:). content := contentWithFilename first: sz - fname size - 1. (directory fileExists: fname) ifFalse: [ + [file := StandardFileStream newFileNamed: (directory fullNameFor: fname). + file nextPutAll: content] + ensure: [file close]]! - StandardFileStream newFileNamed: (directory fullNameFor: fname) do: [ :file | - file nextPutAll: content ] ]!
1
0
0
0
The Trunk: SMBase-gk.110.mcz
by commits@source.squeak.org
08 Nov '11
08 Nov '11
Chris Muller uploaded a new version of SMBase to project The Trunk:
http://source.squeak.org/trunk/SMBase-gk.110.mcz
==================== Summary ==================== Name: SMBase-gk.110 Author: gk Time: 12 April 2010, 1:00:20 am UUID: ce768c9a-89ba-4cd8-803d-21f3f84de496 Ancestors: SMBase-gk.109 Backed out changes to file handling, not compatible with 3.8. =============== Diff against SMBase-gk.109 =============== Item was changed: ----- Method: SMAccount>>newFile:block: (in category 'files') ----- newFile: fileName block: aBlock "Create a new file. Let <aBlock> fill the file with content by calling it with a stream." + | dir stream | - | dir | dir := self uploadsDirectory. + [(dir fileExists: fileName) ifTrue:[dir deleteFileNamed: fileName]. + stream := dir newFileNamed: fileName. + stream binary. + aBlock value: stream] ensure: [stream close]! - (dir fileExists: fileName) ifTrue:[dir deleteFileNamed: fileName]. - dir newFileNamed: fileName do: [:stream | - stream binary. - aBlock value: stream]! Item was changed: ----- Method: SMSqueakMap>>saveCheckpoint: (in category 'checkpoints') ----- saveCheckpoint: contentWithFilename "Save the map checkpoint to disk if it is not there already." + | file directory sz fname content | - | directory sz fname content | directory := self directory. sz := contentWithFilename size. fname := contentWithFilename last: sz - (contentWithFilename lastIndexOf: $:). content := contentWithFilename first: sz - fname size - 1. (directory fileExists: fname) ifFalse: [ + [file := StandardFileStream newFileNamed: (directory fullNameFor: fname). + file nextPutAll: content] + ensure: [file close]]! - StandardFileStream newFileNamed: (directory fullNameFor: fname) do: [ :file | - file nextPutAll: content ] ]!
1
0
0
0
The Trunk: SMBase-gk.110.mcz
by commits@source.squeak.org
08 Nov '11
08 Nov '11
Chris Muller uploaded a new version of SMBase to project The Trunk:
http://source.squeak.org/trunk/SMBase-gk.110.mcz
==================== Summary ==================== Name: SMBase-gk.110 Author: gk Time: 12 April 2010, 1:00:20 am UUID: ce768c9a-89ba-4cd8-803d-21f3f84de496 Ancestors: SMBase-gk.109 Backed out changes to file handling, not compatible with 3.8. =============== Diff against SMBase-gk.109 =============== Item was changed: ----- Method: SMAccount>>newFile:block: (in category 'files') ----- newFile: fileName block: aBlock "Create a new file. Let <aBlock> fill the file with content by calling it with a stream." + | dir stream | - | dir | dir := self uploadsDirectory. + [(dir fileExists: fileName) ifTrue:[dir deleteFileNamed: fileName]. + stream := dir newFileNamed: fileName. + stream binary. + aBlock value: stream] ensure: [stream close]! - (dir fileExists: fileName) ifTrue:[dir deleteFileNamed: fileName]. - dir newFileNamed: fileName do: [:stream | - stream binary. - aBlock value: stream]! Item was changed: ----- Method: SMSqueakMap>>saveCheckpoint: (in category 'checkpoints') ----- saveCheckpoint: contentWithFilename "Save the map checkpoint to disk if it is not there already." + | file directory sz fname content | - | directory sz fname content | directory := self directory. sz := contentWithFilename size. fname := contentWithFilename last: sz - (contentWithFilename lastIndexOf: $:). content := contentWithFilename first: sz - fname size - 1. (directory fileExists: fname) ifFalse: [ + [file := StandardFileStream newFileNamed: (directory fullNameFor: fname). + file nextPutAll: content] + ensure: [file close]]! - StandardFileStream newFileNamed: (directory fullNameFor: fname) do: [ :file | - file nextPutAll: content ] ]!
1
0
0
0
← Newer
1
...
9
10
11
12
13
14
15
16
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Results per page:
10
25
50
100
200