Skip to content

Uncategorized Notes

Corvin Koegler edited this page May 28, 2024 · 4 revisions

Colors

Color can be set using rgb with an alpha channel

[Color r: 0.9 g: 0.75 b: 0.45 alpha: 0.5]

You can select the color of the system window (for colorful windows setting) like this:

windowColorToUse
	^ Color
		colorFrom: (Model useColorfulWindows
				ifTrue: [self userInterfaceTheme customWindowColor
						ifNil: [Color
								r: 0.9
								g: 0.75
								b: 0.45
								alpha: 0.5]]
				ifFalse: [self userInterfaceTheme uniformWindowColor
						ifNil: [Color veryVeryLightGray]])

Morphic Widgets

There are multiple color pickers in the morphic framework. NewColorPickerMorph new openInWorld

Util

write file on accept

Some filout code from the workspace:

fileOutOnAccept
	<preference: 'File-out workspace contents on accept' 
		categoryList: #('browsing' 'tools')
		description: 'If true, accepting contents in a workspace will append them to a file on disk. The file name is derived from the workspace''s current window title and can thus be changed. The default name is thus ''Workspace.text''.'
		type: #Boolean>
	^ FileOutOnAccept ifNil: [ true ]

add custom menu items to dropdown

addModelItemsToWindowMenu: aMenu 
	
	aMenu addLine.
	aMenu
		add: 'change file name...'
		target: self
		action: #changeFileName.
	aMenu
		add: 'save contents to file...'
		target: self
		action: #saveContentsInFile.
	aMenu
		addUpdating: #saveContentsInFileOnAcceptWording
		target: self
		action: #saveContentsInFileOnAccept.
	aMenu
		addUpdating: #appendContentsToFileOnAcceptWording
		target: self
		action: #appendContentsToFileOnAccept.
	aMenu addLine.
	aMenu
		add: 'inspect variables'
		target: self
		action: #inspectBindings.
	aMenu
		add: 'reset variables'
		target: self
		action: #resetBindings.
	aMenu addLine.
	aMenu
		addUpdating: #mustDeclareVariableWording
		target: self
		action: #toggleVariableDeclarationMode.
	aMenu
		addUpdating: #acceptDroppedMorphsWording
		target: self
		action: #toggleDroppingMorphForReference.

	self addToggleStylingMenuItemTo: aMenu.