我对Pharo,Smalltalk是全新的。我正在开发一个小型应用程序,将温度从华氏温度转换为摄氏温度。任何人都可以给我任何想法,如何使用TextMorph创建一个输入字段,并显示在窗口中,如屏幕截图所示。另外,当按钮被点击时能够从输入字段获取数据。下面的代码是我迄今为止所做的。 ScreenshotPharo Smalltalk:如何使用TextMorph创建输入字段,然后从输入字段获取数据?
类TemperatureMorph
BorderedMorph subclass: #TemperatureMorph
instanceVariableNames: 'tempInputField counter'
classVariableNames: ''
package: 'Assignment'
initialize方法:包含一个标签,文本框和按钮。
initialize
| headingLabel converterButton|
super initialize.
self bounds: ([email protected] corner:[email protected]).
self color: Color gray.
headingLabel := StringMorph contents: 'Converter'.
headingLabel position: [email protected]
self addMorph: headingLabel.
tempInputField := TextMorph new.
tempInputField position: [email protected]
self addMorph: tempInputField.
感谢
,解决办法在于权在截图你面前的事实让我不知道你们是否已经尝试自己的东西,并张贴了这个问题之前已经做了一些研究。 – JayK
@Jayk是的。我做了研究,并尝试了自己给你的解决方案,但不幸的是由于我选择的背景,我看不到文本框。 :( –
哦,好吧,那是不好的运气 – JayK