Nicolas Cellier uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-nice.235.mcz ==================== Summary ==================== Name: Graphics-nice.235 Author: nice Time: 29 September 2013, 2:38:15.212 am UUID: dc85806a-22af-482b-b058-88acc8259764 Ancestors: Graphics-nice.234 Correct this glitch: when a text was centered or right flush, clicking at the very left of text morph would incorrectly position the text cursor. =============== Diff against Graphics-nice.234 =============== Item was changed: ----- Method: CharacterBlockScanner>>characterBlockAtPoint:index:in: (in category 'scanning') ----- characterBlockAtPoint: aPoint index: index in: textLine "This method is the Morphic characterBlock finder. It combines + MVC's characterBlockAtPoint:, -ForIndex:, and buildCharacterBlockIn:" - MVC's characterBlockAtPoint:, -ForIndex:, and buildCharcterBlock:in:" | runLength lineStop stopCondition | line := textLine. rightMargin := line rightMargin. lastIndex := line first. self setStopConditions. "also sets font" characterIndex := index. " == nil means scanning for point" characterPoint := aPoint. (characterPoint isNil or: [characterPoint y > line bottom]) ifTrue: [characterPoint := line bottomRight]. + destX := leftMargin := line leftMarginForAlignment: alignment. + destY := line top. + (text isEmpty or: [(characterPoint y < destY or: [characterPoint x < destX]) - (text isEmpty or: [(characterPoint y < line top or: [characterPoint x < line left]) or: [characterIndex notNil and: [characterIndex < line first]]]) ifTrue: [^ (CharacterBlock new stringIndex: line first text: text + topLeft: destX@destY extent: 0 @ textStyle lineGrid) - topLeft: line leftMargin@line top extent: 0 @ textStyle lineGrid) textLine: line]. - destX := leftMargin := line leftMarginForAlignment: alignment. - destY := line top. runLength := text runLengthFor: line first. lineStop := characterIndex "scanning for index" ifNil: [ line last ]. "scanning for point" runStopIndex := lastIndex + (runLength - 1) min: lineStop. lastCharacterExtent := 0 @ line lineHeight. spaceCount := 0. [ stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex in: text string rightX: characterPoint x stopConditions: stopConditions kern: kern. "see setStopConditions for stopping conditions for character block operations." self lastCharacterExtentSetX: (specialWidth ifNil: [font widthOf: (text at: lastIndex)] ifNotNil: [specialWidth]). self perform: stopCondition ] whileFalse. characterIndex ifNil: [ "Result for characterBlockAtPoint: " (stopCondition ~~ #cr and: [ lastIndex == line last and: [ aPoint x > ((characterPoint x) + (lastCharacterExtent x / 2)) ]]) ifTrue: [ "Correct for right half of last character in line" ^ (CharacterBlock new stringIndex: lastIndex + 1 text: text topLeft: characterPoint + (lastCharacterExtent x @ 0) + (font descentKern @ 0) extent: 0 @ lastCharacterExtent y) textLine: line ]. ^ (CharacterBlock new stringIndex: lastIndex text: text topLeft: characterPoint + (font descentKern @ 0) extent: lastCharacterExtent - (font baseKern @ 0)) textLine: line] ifNotNil: ["Result for characterBlockForIndex: " ^ (CharacterBlock new stringIndex: characterIndex text: text topLeft: characterPoint + ((font descentKern) - kern @ 0) extent: lastCharacterExtent) textLine: line]! |
Free forum by Nabble | Edit this page |