[Q] FillInTheBlankMorph>>getUserResponse evil?
Steven Swerling
sps2000 at mail.com
Sun May 12 23:17:01 UTC 2002
Ken,
This was a pet peeve of mine awhile ago. I wrote some tools for modal
support, you might want to give them a try. The ModalDialogs are what I
believe you need -- included are sample MessageBox, ConfirmBox, and
YesNoCancelBox to use as reference for subclassing ModalDialogMorph.
Your code will not continue until there is a response -- eg. doing a
"print it" on
YesNoCancel confirm: 'Does my body lie over the ocean?' title: 'Please
confirm'
will shut out the UI on all but the opened dialog until the user makes a
choice. These "feel" like regular modal windows. They can be nested. If
there is an exception, modality is cancelled automatically. It only
works in Morphic.
See:
http://users.bestweb.net/~swerling/squeak/spsSqueakDocs.html#modalSupport
There is also a nice ComboBoxMorph on this page if anybody wants, this
is a very complicated widget in terms of modality (keyboard events need
to go to the TextMorph, unless they are the up/down arrow keys, in which
case they go to the popup list, mouse events go either to the popup list
or the TextMorph, or if there is a click outside of the popup list, they
close the list). This combo box also has an option to automatically
filter the items in the popup list based on what is typed in the
textmorph. I have been using it for quite awhile now in the SPSBrowser,
it works well. I have tweaked the code a tiny bit since posting the code
on the web page listed above -- let me know if you want the most
up-to-date version.
Steve.
Ken Causey wrote:
>FillInTheBlankMorph>>getUserResponse
> "Wait for the user to accept or cancel, and answer the result string.
>Answers the empty string if the user cancels."
> "Details: This is invoked synchronously from the caller. In order to
>keep processing inputs and updating the screen while waiting for the
>user to respond, this method has its own version of the World's event
>loop."
>
> | w |
> w _ self world.
> w ifNil: [^ response].
> done _ false.
> [done] whileFalse: [World doOneCycle].
> self delete.
> World doOneCycle.
> ^ response
>
>Maybe it's just me, but this seems evil and hacky. However, I'm now in
>the position of needing a slightly more complex dialog and my code
>really wants to wait for the response before continuing. Is this logic
>the current best choice for waiting for a response from the user? I
>can't seem to come up with a better solution so far.
>
>Waiting eagerly,
>
>Ken Causey
>
>
>
>
>
More information about the Squeak-dev
mailing list
|