Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pharo Smalltalk: Reading from TextMorph

In Smalltalk using Pharo, I'm creating an application that reads the user input and does X.

So far I've managed to make a TextMorph that a user could enter a value into, but I'm unsure of how to read from TextMorphs and then do something with the value.

Any ideas?

Thanks

like image 792
Gdohfg Avatar asked May 24 '26 07:05

Gdohfg


1 Answers

Well, you can simply send text to your morph and get it's contents. So you could have a button and when button is pressed you do something with contents:

input := TextMorph new.
button :=
   SimpleButtonMorph new
      target: self
      actionSelector: #processTextMorph:;
      arguments: {input};
      yourself.

processTextMorph: aTextMorph
   | contents |
   contents := aTextMorph text.
   "do something with contents"

However maybe you want to use a dialog? Because you can do:

response := UIManager default request: 'What do you want to do?'.
response ifNotNil: [ "do something with the response" ]

And then the execution of UIManager default request: '…' will open a dialog with a text input

like image 169
Uko Avatar answered May 25 '26 23:05

Uko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!