Patrick Rein uploaded a new version of ToolBuilder-Morphic to project The Trunk:
http://source.squeak.org/trunk/ToolBuilder-Morphic-pre.221.mcz
==================== Summary ====================
Name: ToolBuilder-Morphic-pre.221
Author: pre
Time: 1 November 2018, 2:48:52.569001 pm
UUID: ab161364-1d81-e043-b4d0-eed4c48d03ee
Ancestors: ToolBuilder-Morphic-cmm.220
Refactors the MorphicUIManager to capture and use the ProvideAnswerNotification
=============== Diff against ToolBuilder-Morphic-cmm.220 ===============
Item was changed:
----- Method: MorphicUIManager>>chooseDirectory:from: (in category 'ui requests') -----
chooseDirectory: label from: dir
+ "Let the user choose a file matching the given patterns. Returns a file name."
+ self askForProvidedAnswerTo: label ifSupplied: [:answer |
+ ^ answer].
+
+ ^ DirectoryChooserDialog openOn: dir label: label!
- "Let the user choose a directory"
-
- ^DirectoryChooserDialog openOn: dir label: label!
Item was changed:
----- Method: MorphicUIManager>>chooseFileMatching:label: (in category 'ui requests') -----
chooseFileMatching: patterns label: aString
+ "Let the user choose a file matching the given patterns. Returns a file name."
+ self askForProvidedAnswerTo: aString ifSupplied: [:answer |
+ ^ answer].
+
+ ^ FileChooserDialog openOnPattern: patterns label: aString!
- "Let the user choose a file matching the given patterns"
- | result |
- result := FileChooserDialog openOnPattern: patterns label: aString.
- ^result!
Item was changed:
----- Method: MorphicUIManager>>chooseFileMatchingSuffixes:label: (in category 'ui requests') -----
chooseFileMatchingSuffixes: suffixList label: aString
+ "Let the user choose a file matching the given suffixes. Returns a file name."
+ self askForProvidedAnswerTo: aString ifSupplied: [:answer |
+ ^ answer].
+
+ ^ FileChooserDialog openOnSuffixList: suffixList label: aString.
+ !
- "Let the user choose a file matching the given suffix list"
- | result |
- result := FileChooserDialog openOnSuffixList: suffixList label: aString.
- ^result!
Item was changed:
----- Method: MorphicUIManager>>chooseFont:for:setSelector:getSelector: (in category 'ui requests') -----
chooseFont: titleString for: aModel setSelector: setSelector getSelector: getSelector
"Open a font-chooser for the given model"
+ self askForProvidedAnswerTo: titleString ifSupplied: [:answer |
+ ^ answer].
+
^FontChooserTool default
openWithWindowTitle: titleString
for: aModel
setSelector: setSelector
getSelector: getSelector!
Item was changed:
----- Method: MorphicUIManager>>chooseFrom:lines:title: (in category 'ui requests') -----
chooseFrom: aList lines: linesArray title: aString
"Choose an item from the given list. Answer the index of the selected item. Cancel value is 0.
There are several (historical) reasons for building a button dialog instead of a list chooser for small lists:
1) Unfortunately, there is existing code that uses this call to create simple confirmation dialogs with a list of #(yes no cancel).
2) Unfortunately, there is existing code that uses this call to mimick a drop-down menu with a (compact) pop-up menu."
+ self askForProvidedAnswerTo: aString ifSupplied: [:answer |
+ (answer = #cancel or: [answer isNil]) ifTrue: [^ 0].
+ ^ aList indexOf: answer].
aList ifEmpty: [^ 0].
aList size <= 7 ifTrue: [
| dialog |
dialog := DialogWindow new
title: 'Please Choose';
message: aString;
filterEnabled: true;
autoCancel: true; "Like a pop-up menu, click anywhere to dismiss."
yourself.
aList doWithIndex: [:ea :index |
dialog createButton: ea value: index].
dialog selectedButtonIndex: 1.
^ dialog getUserResponseAtHand ifNil: [0]].
^ ListChooser chooseFrom: aList title: aString!
Item was changed:
----- Method: MorphicUIManager>>chooseFrom:values:lines:title: (in category 'ui requests') -----
chooseFrom: labelList values: valueList lines: linesArray title: aString
"Choose an item from the given list. Answer the selected item."
| index |
+ self askForProvidedAnswerTo: aString ifSupplied: [:answer |
+ (answer = #cancel or: [answer isNil]) ifTrue: [^ nil].
+ ^ valueList at: (valueList indexOf: answer) ifAbsent: [nil]].
+
index := self chooseFrom: labelList lines: linesArray title: aString.
^ index = 0
ifTrue: [ nil ]
ifFalse: [ valueList at: index ]!
Item was changed:
----- Method: MorphicUIManager>>chooseFromOrAddTo:lines:title: (in category 'ui requests') -----
chooseFromOrAddTo: aList lines: linesArray title: aString
+ self askForProvidedAnswerTo: aString ifSupplied: [:answer |
+ ^ answer].
+
^ ListChooser
chooseItemFrom: aList
title: aString
addAllowed: true!
Item was changed:
----- Method: MorphicUIManager>>chooseMultipleFrom:lines:title: (in category 'ui requests') -----
chooseMultipleFrom: aList lines: linesArray title: aString
"Choose one or more items from the given list. Answer the indices of the selected items."
+ self askForProvidedAnswerTo: aString ifSupplied: [:answer |
+ ^ answer].
+
^ ListMultipleChooser
chooseFrom: aList
title: aString!
Item was changed:
----- Method: MorphicUIManager>>chooseMultipleFrom:values:lines:title: (in category 'ui requests') -----
chooseMultipleFrom: labelList values: valueList lines: linesArray title: aString
"Choose one or more items from the given list. Answer the selected items."
+ self askForProvidedAnswerTo: aString ifSupplied: [:answer |
+ ^ answer].
+
^ (ListMultipleChooser
chooseFrom: labelList
title: aString) ifNotNil: [:indexList |
indexList collect: [:index | valueList at: index]]!
Item was changed:
----- Method: MorphicUIManager>>confirm: (in category 'ui requests') -----
confirm: queryString
"Put up a yes/no menu with caption queryString. Answer true if the
response is yes, false if no. This is a modal question--the user must
respond yes or no."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer].
+
+ ^ UserDialogBoxMorph confirm: queryString!
- ^UserDialogBoxMorph confirm: queryString!
Item was changed:
----- Method: MorphicUIManager>>confirm:orCancel: (in category 'ui requests') -----
confirm: aString orCancel: cancelBlock
"Put up a yes/no/cancel menu with caption aString. Answer true if
the response is yes, false if no. If cancel is chosen, evaluate
cancelBlock. This is a modal question--the user must respond yes or no."
+ self askForProvidedAnswerTo: aString ifSupplied: [:answer |
+ ^ (answer = #cancel or: [answer isNil])
+ ifTrue: [cancelBlock value]
+ ifFalse: [answer]].
+
+ ^ UserDialogBoxMorph confirm: aString orCancel: cancelBlock!
- ^UserDialogBoxMorph confirm: aString orCancel: cancelBlock!
Item was changed:
----- Method: MorphicUIManager>>confirm:orCancel:title: (in category 'ui requests') -----
confirm: aString orCancel: cancelBlock title: titleString
"Put up a yes/no/cancel menu with caption aString, and titleString to label the dialog.
Answer true if the response is yes, false if no. If cancel is chosen, evaluate cancelBlock.
This is a modal question--the user must respond yes or no."
+ self askForProvidedAnswerTo: aString ifSupplied: [:answer |
+ ^ (answer = #cancel or: [answer isNil])
+ ifTrue: [cancelBlock value]
+ ifFalse: [answer]].
+
^ UserDialogBoxMorph
confirm: aString
orCancel: cancelBlock
title: titleString
at: nil!
Item was changed:
----- Method: MorphicUIManager>>confirm:title: (in category 'ui requests') -----
confirm: queryString title: titleString
"Put up a yes/no menu with caption queryString, and titleString to label the dialog.
Answer true if the response is yes, false if no. This is a modal question--the user
must respond yes or no."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer].
+
+ ^ UserDialogBoxMorph confirm: queryString title: titleString!
- ^UserDialogBoxMorph confirm: queryString title: titleString!
Item was changed:
----- Method: MorphicUIManager>>confirm:title:trueChoice:falseChoice: (in category 'ui requests') -----
confirm: queryString title: titleString trueChoice: trueChoice falseChoice: falseChoice
"Put up a yes/no menu with caption queryString, and titleString to label the dialog.
The actual wording for the two choices will be as provided in the trueChoice and
falseChoice parameters. Answer true if the response is the true-choice, false if it
is the false-choice. This is a modal question -- the user must respond one way or
the other."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer isBoolean
+ ifTrue: [answer]
+ ifFalse: [trueChoice = answer]].
+
^ UserDialogBoxMorph confirm: queryString title: titleString trueChoice: trueChoice falseChoice: falseChoice !
Item was changed:
----- Method: MorphicUIManager>>confirm:trueChoice:falseChoice: (in category 'ui requests') -----
confirm: queryString trueChoice: trueChoice falseChoice: falseChoice
"Put up a yes/no menu with caption queryString. The actual wording for the two choices will be as provided in the trueChoice and falseChoice parameters. Answer true if the response is the true-choice, false if it's the false-choice.
This is a modal question -- the user must respond one way or the other."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer].
+
^ UserDialogBoxMorph confirm: queryString trueChoice: trueChoice falseChoice: falseChoice !
Item was changed:
----- Method: MorphicUIManager>>edit:label:accept: (in category 'ui requests') -----
edit: aText label: labelString accept: anAction
"Open an editor on the given string/text"
| window |
window := Workspace open.
labelString ifNotNil: [ window setLabel: labelString ].
"By default, don't style in UIManager edit: requests"
window model
shouldStyle: false;
acceptContents: aText;
acceptAction: anAction.
+ ^ window!
- ^window.!
Item was changed:
----- Method: MorphicUIManager>>inform: (in category 'ui requests') -----
inform: aString
"Display a message for the user to read and then dismiss"
+ self askForProvidedAnswerTo: aString ifSupplied: [:answer |
+ ^ answer].
+
+ ^ UserDialogBoxMorph inform: aString!
- ^UserDialogBoxMorph inform: aString!
Item was changed:
----- Method: MorphicUIManager>>multiLineRequest:centerAt:initialAnswer:answerHeight: (in category 'ui requests') -----
multiLineRequest: queryString centerAt: aPoint initialAnswer: defaultAnswer answerHeight: answerHeight
"Create a multi-line instance of me whose question is queryString with
the given initial answer. Invoke it centered at the given point, and
answer the string the user accepts. Answer nil if the user cancels. An
empty string returned means that the ussr cleared the editing area and
then hit 'accept'. Because multiple lines are invited, we ask that the user
use the ENTER key, or (in morphic anyway) hit the 'accept' button, to
submit; that way, the return key can be typed to move to the next line."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer = #default
+ ifTrue: [defaultAnswer]
+ ifFalse: [answer]].
+
+ ^ FillInTheBlankMorph
- ^FillInTheBlankMorph
request: queryString
initialAnswer: defaultAnswer
centerAt: aPoint
inWorld: self currentWorld
onCancelReturn: nil
acceptOnCR: false!
Item was changed:
----- Method: MorphicUIManager>>openDebugger:on:context:label:contents:fullView: (in category 'ui project indirecting') -----
openDebugger: aDebugger on: process context: context label: title contents: contentsStringOrNil fullView: bool
"open a debugger - the two versions for mvc & morphic are very close and can surely be merged so that this can be removed"
+ ^ aDebugger morphicOpenOn: process context: context label: title contents: contentsStringOrNil fullView: bool!
- ^aDebugger morphicOpenOn: process context: context label: title contents: contentsStringOrNil fullView: bool!
Item was changed:
----- Method: MorphicUIManager>>request:initialAnswer: (in category 'ui requests') -----
request: queryString initialAnswer: defaultAnswer
"Create an instance of me whose question is queryString with the given
initial answer. Invoke it centered at the given point, and answer the
string the user accepts. Answer the empty string if the user cancels."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer = #default
+ ifTrue: [defaultAnswer]
+ ifFalse: [answer]].
+
^FillInTheBlankMorph request: queryString initialAnswer: defaultAnswer !
Item was changed:
----- Method: MorphicUIManager>>request:initialAnswer:centerAt: (in category 'ui requests') -----
request: queryString initialAnswer: defaultAnswer centerAt: aPoint
"Create an instance of me whose question is queryString with the given
initial answer. Invoke it centered at the given point, and answer the
string the user accepts. Answer the empty string if the user cancels."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer = #default
+ ifTrue: [defaultAnswer]
+ ifFalse: [answer]].
+
+ ^ FillInTheBlankMorph request: queryString initialAnswer: defaultAnswer centerAt: aPoint!
- ^FillInTheBlankMorph request: queryString initialAnswer: defaultAnswer centerAt: aPoint!
Item was changed:
----- Method: MorphicUIManager>>requestPassword: (in category 'ui requests') -----
requestPassword: queryString
"Create an instance of me whose question is queryString. Invoke it centered
at the cursor, and answer the string the user accepts. Answer the empty
string if the user cancels."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer].
+
+ ^ FillInTheBlankMorph requestPassword: queryString!
- ^FillInTheBlankMorph requestPassword: queryString!
Item was changed:
----- Method: MorphicUIManager>>saveFilenameRequest:initialAnswer: (in category 'ui requests') -----
saveFilenameRequest: queryString initialAnswer: defaultAnswer
"Open a FileSaverDialog to ask for a place and filename to use for saving a file. The initial suggestion for the filename is defaultAnswer but the user may choose any existing file or type in a new name entirely"
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer = #default
+ ifTrue: [defaultAnswer]
+ ifFalse: [answer]].
+ ^ FileSaverDialog openOnInitialFilename: defaultAnswer label: queryString
- ^FileSaverDialog openOnInitialFilename: defaultAnswer label: queryString
!
Patrick Rein uploaded a new version of ToolBuilder-MVC to project The Trunk:
http://source.squeak.org/trunk/ToolBuilder-MVC-pre.54.mcz
==================== Summary ====================
Name: ToolBuilder-MVC-pre.54
Author: pre
Time: 1 November 2018, 2:48:01.588001 pm
UUID: e488697b-2d4c-1143-bd7a-bdd8ff4c8b0c
Ancestors: ToolBuilder-MVC-tpr.53
Refactors the MVCUIManager to capture and use the ProvideAnswerNotification
=============== Diff against ToolBuilder-MVC-tpr.53 ===============
Item was changed:
----- Method: MVCUIManager>>chooseFileMatching:label: (in category 'ui requests') -----
chooseFileMatching: patterns label: labelString
+ "Let the user choose a file matching the given patterns. Returns a file name."
- "Let the user choose a file matching the given patterns"
^self notYetImplemented!
Item was changed:
----- Method: MVCUIManager>>chooseFileMatchingSuffixes:label: (in category 'ui requests') -----
chooseFileMatchingSuffixes: suffixList label: aString
+ "Let the user choose a file matching the given suffixes. Returns a file name."
- "Let the user choose a file matching the given suffix list"
^self notYetImplemented!
Item was changed:
----- Method: MVCUIManager>>chooseFont:for:setSelector:getSelector: (in category 'ui requests') -----
chooseFont: aPrompt for: aTarget setSelector: setSelector getSelector: getSelector
"MVC Only!! prompt for a font and if one is provided, send it to aTarget using a message with selector aSelector."
| aMenu aChoice aStyle namesAndSizes aFont |
+ self askForProvidedAnswerTo: aPrompt ifSupplied: [:answer |
+ ^ answer].
+
aMenu := CustomMenu new.
TextStyle actualTextStyles keysSortedSafely do:
[:styleName |
aMenu add: styleName action: styleName].
aChoice := aMenu startUpWithCaption: aPrompt.
aChoice ifNil: [^ self].
aMenu := CustomMenu new.
aStyle := TextStyle named: aChoice.
(namesAndSizes := aStyle fontNamesWithPointSizes) do:
[:aString | aMenu add: aString action: aString].
aChoice := aMenu startUpWithCaption: nil.
aChoice ifNil: [^ self].
aFont := aStyle fontAt: (namesAndSizes indexOf: aChoice).
aTarget perform: setSelector with: aFont!
Item was changed:
----- Method: MVCUIManager>>chooseFrom:lines:title: (in category 'ui requests') -----
chooseFrom: aList lines: linesArray title: aString
"Choose an item from the given list. Answer the index of the selected item."
| menu |
+ self askForProvidedAnswerTo: aString ifSupplied: [:answer |
+ (answer = #cancel or: [answer isNil]) ifTrue: [^ 0].
+ ^ aList indexOf: answer].
+
menu := PopUpMenu labelArray: aList lines: linesArray.
+ ^ aString isEmpty ifTrue:[menu startUp] ifFalse:[menu startUpWithCaption: aString]!
- ^aString isEmpty ifTrue:[menu startUp] ifFalse:[menu startUpWithCaption: aString]!
Item was changed:
----- Method: MVCUIManager>>chooseFrom:values:lines:title: (in category 'ui requests') -----
chooseFrom: labelList values: valueList lines: linesArray title: aString
"Choose an item from the given list. Answer the selected item."
| menu |
+ self askForProvidedAnswerTo: aString ifSupplied: [:answer |
+ (answer = #cancel or: [answer isNil]) ifTrue: [^ nil].
+ ^ valueList at: (valueList indexOf: answer)].
+
menu := SelectionMenu labels: labelList lines: linesArray selections: valueList.
+ ^ aString
+ ifEmpty: [menu startUp]
+ ifNotEmpty: [menu startUpWithCaption: aString]!
- ^aString isEmpty ifTrue:[menu startUp] ifFalse:[menu startUpWithCaption: aString]!
Item was changed:
----- Method: MVCUIManager>>confirm: (in category 'ui requests') -----
confirm: queryString
"Put up a yes/no menu with caption queryString. Answer true if the
response is yes, false if no. This is a modal question--the user must
respond yes or no."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer].
+
+ ^ PopUpMenu confirm: queryString!
- ^PopUpMenu confirm: queryString!
Item was changed:
----- Method: MVCUIManager>>confirm:orCancel: (in category 'ui requests') -----
confirm: aString orCancel: cancelBlock
"Put up a yes/no/cancel menu with caption aString. Answer true if
the response is yes, false if no. If cancel is chosen, evaluate
cancelBlock. This is a modal question--the user must respond yes or no."
+ self askForProvidedAnswerTo: aString ifSupplied: [:answer |
+ ^ (answer = #cancel or: [answer isNil])
+ ifTrue: [cancelBlock value]
+ ifFalse: [answer]].
+
+ ^ PopUpMenu confirm: aString orCancel: cancelBlock!
- ^PopUpMenu confirm: aString orCancel: cancelBlock!
Item was changed:
----- Method: MVCUIManager>>confirm:orCancel:title: (in category 'ui requests') -----
confirm: aString orCancel: cancelBlock title: titleString
"Put up a yes/no/cancel menu with caption aString, and titleString to label the dialog.
Answer true if the response is yes, false if no. If cancel is chosen, evaluate cancelBlock.
This is a modal question--the user must respond yes or no."
+ self askForProvidedAnswerTo: aString ifSupplied: [:answer |
+ ^ (answer = #cancel or: [answer isNil])
+ ifTrue: [cancelBlock value]
+ ifFalse: [answer]].
+
^ PopUpMenu
confirm: (self dialogStringFromQuery: aString withTitle: titleString)
orCancel: cancelBlock!
Item was changed:
----- Method: MVCUIManager>>confirm:title: (in category 'ui requests') -----
confirm: queryString title: titleString
"Put up a yes/no menu with caption queryString, and titleString to label the dialog.
Answer true if the response is yes, false if no. This is a modal question--the user
must respond yes or no."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer].
+
+ ^ PopUpMenu confirm: (self dialogStringFromQuery: queryString withTitle: titleString)
- ^PopUpMenu confirm: (self dialogStringFromQuery: queryString withTitle: titleString)
!
Item was changed:
----- Method: MVCUIManager>>confirm:title:trueChoice:falseChoice: (in category 'ui requests') -----
confirm: queryString title: titleString trueChoice: trueChoice falseChoice: falseChoice
"Put up a yes/no menu with caption queryString, and titleString to label the dialog.
The actual wording for the two choices will be as provided in the trueChoice and
falseChoice parameters. Answer true if the response is the true-choice, false if it
is the false-choice. This is a modal question -- the user must respond one way or
the other."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer isBoolean
+ ifTrue: [answer]
+ ifFalse: [trueChoice = answer]].
+
^ PopUpMenu
confirm: (self dialogStringFromQuery: queryString withTitle: titleString)
trueChoice: trueChoice
falseChoice: falseChoice!
Item was changed:
----- Method: MVCUIManager>>confirm:trueChoice:falseChoice: (in category 'ui requests') -----
confirm: queryString trueChoice: trueChoice falseChoice: falseChoice
"Put up a yes/no menu with caption queryString. The actual wording for the two choices will be as provided in the trueChoice and falseChoice parameters. Answer true if the response is the true-choice, false if it's the false-choice.
This is a modal question -- the user must respond one way or the other."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer].
+
+ ^ PopUpMenu confirm: queryString trueChoice: trueChoice falseChoice: falseChoice!
- ^PopUpMenu confirm: queryString trueChoice: trueChoice falseChoice: falseChoice!
Item was changed:
----- Method: MVCUIManager>>inform: (in category 'ui requests') -----
inform: aString
"Display a message for the user to read and then dismiss"
+ self askForProvidedAnswerTo: aString ifSupplied: [:answer |
+ ^ answer].
+
+ ^ PopUpMenu inform: aString!
- ^PopUpMenu inform: aString!
Item was changed:
----- Method: MVCUIManager>>multiLineRequest:centerAt:initialAnswer:answerHeight: (in category 'ui requests') -----
multiLineRequest: queryString centerAt: aPoint initialAnswer: defaultAnswer answerHeight: answerHeight
"Create a multi-line instance of me whose question is queryString with
the given initial answer. Invoke it centered at the given point, and
answer the string the user accepts. Answer nil if the user cancels. An
empty string returned means that the ussr cleared the editing area and
then hit 'accept'. Because multiple lines are invited, we ask that the user
use the ENTER key, or (in morphic anyway) hit the 'accept' button, to
submit; that way, the return key can be typed to move to the next line."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer = #default
+ ifTrue: [defaultAnswer]
+ ifFalse: [answer]].
+
+ ^ FillInTheBlank
+ multiLineRequest: queryString
+ centerAt: aPoint
+ initialAnswer: defaultAnswer
+ answerHeight: answerHeight!
- ^FillInTheBlank multiLineRequest: queryString centerAt: aPoint initialAnswer: defaultAnswer answerHeight: answerHeight!
Item was changed:
----- Method: MVCUIManager>>request:initialAnswer: (in category 'ui requests') -----
request: queryString initialAnswer: defaultAnswer
"Create an instance of me whose question is queryString with the given
initial answer. Invoke it centered at the given point, and answer the
string the user accepts. Answer the empty string if the user cancels."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer = #default
+ ifTrue: [defaultAnswer]
+ ifFalse: [answer]].
+
^FillInTheBlank request: queryString initialAnswer: defaultAnswer !
Item was changed:
----- Method: MVCUIManager>>request:initialAnswer:centerAt: (in category 'ui requests') -----
request: queryString initialAnswer: defaultAnswer centerAt: aPoint
"Create an instance of me whose question is queryString with the given
initial answer. Invoke it centered at the given point, and answer the
string the user accepts. Answer the empty string if the user cancels."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer = #default
+ ifTrue: [defaultAnswer]
+ ifFalse: [answer]].
+
^ FillInTheBlank request: queryString initialAnswer: defaultAnswer centerAt: aPoint !
Item was changed:
----- Method: MVCUIManager>>requestPassword: (in category 'ui requests') -----
requestPassword: queryString
"Create an instance of me whose question is queryString. Invoke it centered
at the cursor, and answer the string the user accepts. Answer the empty
string if the user cancels."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer].
+
+ ^ FillInTheBlank requestPassword: queryString!
- ^FillInTheBlank requestPassword: queryString!
Item was changed:
----- Method: MVCUIManager>>saveFilenameRequest:initialAnswer: (in category 'ui requests') -----
saveFilenameRequest: queryString initialAnswer: defaultAnswer
"Open a FileSaverDialog to ask for a place and filename to use for saving a file. The initial suggestion for the filename is defaultAnswer but the user may choose any existing file or type in a new name entirely"
"MVC has to stick with the boring way of doing it"
| result |
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer = #default
+ ifTrue: [defaultAnswer]
+ ifFalse: [answer]].
+
result := self request: queryString initialAnswer: defaultAnswer.
^result isEmpty ifTrue: [nil] ifFalse:[result]
!
Patrick Rein uploaded a new version of ToolBuilder-Kernel to project The Trunk:
http://source.squeak.org/trunk/ToolBuilder-Kernel-pre.123.mcz
==================== Summary ====================
Name: ToolBuilder-Kernel-pre.123
Author: pre
Time: 1 November 2018, 2:44:21.41256 pm
UUID: d880547f-7367-ba4e-ae6c-e6069f68fcec
Ancestors: ToolBuilder-Kernel-pre.122
Updates the comments of the UIManager methods and adds a utility method to make use of the ProvideAnswerNotification mechanism.
=============== Diff against ToolBuilder-Kernel-pre.122 ===============
Item was added:
+ ----- Method: UIManager>>askForProvidedAnswerTo:ifSupplied: (in category 'utilities') -----
+ askForProvidedAnswerTo: queryString ifSupplied: supplyBlock
+
+ ^ (ProvideAnswerNotification signal: queryString asString) ifNotNil: supplyBlock!
Item was changed:
----- Method: UIManager>>chooseDirectory (in category 'ui requests - files') -----
chooseDirectory
+ "Let the user choose a directory. Returns a proper directory."
- "Let the user choose a directory"
^self chooseDirectoryFrom: FileDirectory default!
Item was changed:
----- Method: UIManager>>chooseDirectory: (in category 'ui requests - files') -----
chooseDirectory: label
+ "Let the user choose a directory. Returns a proper directory."
- "Let the user choose a directory"
^self chooseDirectory: label from: FileDirectory default!
Item was changed:
----- Method: UIManager>>chooseDirectory:from: (in category 'ui requests - files') -----
chooseDirectory: label from: dir
+ "Let the user choose a directory. Returns a proper directory."
+ "UIManager default chooseDirectory: 'Choose one' from: FileDirectory default"
- "Let the user choose a directory"
^self subclassResponsibility!
Item was changed:
----- Method: UIManager>>chooseDirectoryFrom: (in category 'ui requests - files') -----
chooseDirectoryFrom: dir
+ "Let the user choose a directory. Returns a proper directory."
- "Let the user choose a directory"
^self chooseDirectory: nil from: dir!
Item was changed:
----- Method: UIManager>>chooseFileMatching: (in category 'ui requests - files') -----
chooseFileMatching: patterns
+ "Let the user choose a file matching the given patterns. Returns a file name."
- "Let the user choose a file matching the given patterns"
^self chooseFileMatching: patterns label: nil!
Item was changed:
----- Method: UIManager>>chooseFileMatching:label: (in category 'ui requests - files') -----
chooseFileMatching: patterns label: labelString
+ "Let the user choose a file matching the given patterns. Returns a file name."
- "Let the user choose a file matching the given patterns"
^self subclassResponsibility!
Item was changed:
----- Method: UIManager>>chooseFileMatchingSuffixes: (in category 'ui requests - files') -----
chooseFileMatchingSuffixes: suffixList
+ "Let the user choose a file matching the given suffixes. Returns a file name."
- "Let the user choose a file matching the given suffixes"
^self chooseFileMatchingSuffixes: suffixList label: nil!
Item was changed:
----- Method: UIManager>>chooseFileMatchingSuffixes:label: (in category 'ui requests - files') -----
chooseFileMatchingSuffixes: suffixList label: labelString
+ "Let the user choose a file matching the given suffixes. Returns a file name."
- "Let the user choose a file matching the given suffixes"
^self subclassResponsibility!
Item was changed:
----- Method: UIManager>>saveFilenameRequest:initialAnswer: (in category 'ui requests - files') -----
saveFilenameRequest: queryString initialAnswer: defaultAnswer
+ "Open a FileSaverDialog to ask for a place and filename to use for saving a file. The initial suggestion for the filename is defaultAnswer but the user may choose any existing file or type in a new name entirely. Returns a file name."
- "Open a FileSaverDialog to ask for a place and filename to use for saving a file. The initial suggestion for the filename is defaultAnswer but the user may choose any existing file or type in a new name entirely"
^self subclassResponsibility!