Creating the Find Dialog window
Create a new visual part named FindDialog which resembles the FindDialog In the Composition Editor add your parts as follows:
1. Add a Text part, a Label part, and two Push Button parts labeled OK and Cancel to the Window part.
2. Add a Variable part to the free-form surface.
3. Change the name of the Variable part to MLE.
4. Change the type of the Variable part to AbtMultiLineEditView, which is the class name of the VA Smalltalk Multi-line Edit part.
5. Promote the self attribute of the MLE part to the public interface of the Find dialog.
Switch to the Script Editor and add the following script:
findText: text inText: anMLE
"Find and select the input text in the input MLE."
 
| searchText cursor interval |
searchText := anMLE object.
cursor := (anMLE) cursorPosition.
interval := searchText indexOf:
text matchCase: true
startingAt: cursor + 1. "or cursor + 2"
(interval size = 0)
ifFalse: [
anMLE cursorPosition: (interval first).
anMLE selectTextFrom: ((interval first) - 1)
to: (interval last).
anMLE setFocus ].
This script will search the Multi-line Edit part for the first occurrence of the desired text after the Multi-line Edit part's current cursor position. If the text is found it will be selected in the Multi-line Edit part, which results in the cursor being positioned immediately after the desired text.
Making the connections
Switch back the the Composition Editor and make the following connections:
1. Connect the clicked event of the Cancel push button to the closeWidget action of the Window part.
2. Connect the clicked event of the OK push button to the script you just created.
3. Connect the object attribute of the Text part to the parameter1 attribute of the event-to-script connection you just created.
4. Connect the self attribute of the MLE part to the parameter2 attribute of the event-to-script connection.
Your connections should look like the following:
Connections
After you finish making the connections, save your part.
Last modified date: 07/16/2020