Hello KMO i follow your step one by one and make the form but i want to run : connectPresenters myButton whenActivatedDo: [LibC system: 'a.bat', myTextField asString]. That means when i put any value in text field than press click me than that value need to send to my bat file as string. so i dont know is that ok or not. but if i write: myButton whenActivatedDo: [LibC system: 'a.bat 10']. than its work perfectly but my concern is to get the value from text field not the fixed value. SO i think i am doing in the wrong things. Please help me with this issue. Thanks a lot kmo wrote
This code should give you a clue of how to do what you want. You can file it in or type it in yourself. You can run it from the playground with the command -
SimpleExample new openWithSpec.
How it works - You need to subclass SpPresenter. You need to set up an instance method called initializePresenters to create a text input and a button. You then create aninstance method called connectPresenters to put a handler on to the button.
You need a class side method called defaultSpec to layout the button and the text input
That's it.
Note that you have to hit enter to register any change in the text field. You will need the transcript open to see the results in this example.
Hope this helps
SpPresenter subclass: #SimpleExample instanceVariableNames: 'myButton myTextField' classVariableNames: '' package: 'KMP-SimpleSpecExample'!
!SimpleExample methodsFor: 'as yet unclassified' stamp: 'KMP 7/28/2020 16:20'! initialize super initialize ! !
!SimpleExample methodsFor: 'initialization' stamp: 'KMP 7/28/2020 16:31'! initializePresenters myButton := self newButton . myButton label:'Click Me'. myTextField := self newTextInput. ! !
!SimpleExample methodsFor: 'initialization' stamp: 'KMP 7/28/2020 16:29'! connectPresenters "Put what you want to do when the button is clicked hhere" myButton whenActivatedDo: [ Transcript show: myTextField text].! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
SimpleExample class instanceVariableNames: ''!
!SimpleExample class methodsFor: 'specs' stamp: 'KMP 7/28/2020 16:30'! defaultSpec
^ SpBoxLayout newVertical borderWidth: 10; spacing: 10; add: #myTextField expand: false; add: #myButton expand: false; yourself! !
-- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
-- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html