[etoys-dev] Etoys Inbox: GSoC-Utils-Richo.1.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Aug 7 12:31:03 EDT 2010

A new version of GSoC-Utils was added to project Etoys Inbox:

==================== Summary ====================

Name: GSoC-Utils-Richo.1
Author: Richo
Time: 6 July 2010, 12:06:48 pm
UUID: 04cd4198-0d2c-594f-809b-69ff652ecae3

* Splitting GSoC package

==================== Snapshot ====================

SystemOrganization addCategory: #'GSoC-Utils'!

TextMorph subclass: #GSoCTextMorph
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'GSoC-Utils'!

!GSoCTextMorph commentStamp: '<historical>' prior: 0!
TextMorph that changes the focus to the next object when pressing <Enter>. It also changes the border color when has focus.
I know a whole new class for these purposes only it's ugly but I don't know how to do this easily using just TextMorph.!

----- Method: GSoCTextMorph>>getNumericValue (in category 'as yet unclassified') -----
 | result |
^[result := Compiler evaluate: text string notifying: SyntaxErrorOmission new logged: false.
	result isNumber ifTrue: [result] ifFalse: [0]] on: Error do: [0]!

----- Method: GSoCTextMorph>>handleKeystroke: (in category 'as yet unclassified') -----
handleKeystroke: anEvent
	"System level event handling."

	| pasteUp |
	anEvent wasHandled ifTrue:[^self].
	(self handlesKeyboard: anEvent) ifFalse:	[^ self].
	anEvent wasHandled: true.
	((anEvent keyCharacter = Character tab) or: [anEvent keyCharacter = Character cr]) ifTrue:
		["Allow passing through text morph inside pasteups"
		(self wouldAcceptKeyboardFocusUponTab and:
				[(pasteUp _ self pasteUpMorphHandlingTabAmongFields) notNil])
			ifTrue:[^ pasteUp tabHitWithEvent: anEvent]].
	self keyStroke: anEvent!

----- Method: GSoCTextMorph>>initialize (in category 'as yet unclassified') -----
super initialize.!

----- Method: GSoCTextMorph>>keyboardFocusChange: (in category 'as yet unclassified') -----
keyboardFocusChange: aBoolean 
super keyboardFocusChange: aBoolean.
aBoolean ifTrue: [self borderColor: Color red]  ifFalse: [self borderColor: Color black]!

----- Method: GSoCTextMorph>>setExtentFromHalo: (in category 'as yet unclassified') -----
setExtentFromHalo: aPoint
	super setExtentFromHalo: aPoint.
	(owner respondsTo: #notifyExtentChange:) ifTrue: [owner notifyExtentChange: self]!

Object subclass: #SyntaxErrorOmission
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'GSoC-Utils'!

!SyntaxErrorOmission commentStamp: 'Richo 5/16/2010 13:41' prior: 0!
This object is only used to avoid a SyntaxError dialog when doing Compiler>>#evaluate:notifying:logged:. It simply omits the message.
The Compiler stuff is done in the table morphs to get a number from the text. I know it should be easy to simply sent #asNumber to the string, but I did it this way because it allows to write stuff like:

'Float pi'
'15 * 6'!

----- Method: SyntaxErrorOmission>>notify:at:in: (in category 'as yet unclassified') -----
notify: aByteString at: aSmallInteger in: aReadStream 

----- Method: SyntaxErrorOmission>>selectionInterval (in category 'as yet unclassified') -----
^(0 to: 0)!

----- Method: SyntaxErrorOmission>>text (in category 'as yet unclassified') -----
^Text new!

ScrollPane subclass: #GSoCScrollPane
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'GSoC-Utils'!

!GSoCScrollPane commentStamp: '<historical>' prior: 0!
A ScrollPane that defers its halo to interior!

----- Method: GSoCScrollPane>>defersHaloToInteriorMorph: (in category 'as yet unclassified') -----
defersHaloToInteriorMorph: aMorph

More information about the etoys-dev mailing list