[Gambas-user] Clearing data from TextAreas & ListBoxes
John Rose
john.aaron.rose at ...626...
Mon Mar 2 21:16:15 CET 2015
Tobi,
I changed coding to:
Public Sub RunButton_Click()
...
StopListBox.Clear
SteckersListBox.Clear
ReflectorListBox.Clear
RotorsListBox.Clear
DetailTextArea.Clear
Wait
...
aExecParameters = ["/opt/Enigma/turing_bombe_all_wheels", sMenuPath]
'sMenuPath points to an input file
pturing_bombe = Exec aExecParameters Wait For Read As
"TuringBombeResultsDetail"
...
PopulateListBoxesFromDetailsTextArea
...
End
Public Sub TuringBombeResultsDetail_Read()
Dim sLine As String
Line Input #Last, sLine
Print "SO=" & sLine
DetailTextArea.Text &= sLine & "\n"
Wait
End
It still did not clear the displayed contents of those controls. I
clicked the button once (i.e. when the contents were already clear) and
it populated the above controls as expected. I clicked the button again
but it did not clear the DetailTextArea or the ListBoxes immediately.
The CL program took a few seconds to run and interestingly when it
finished it did not add to the controls' contents (i.e. it cleared them
before populating them again).
John
On 02/03/15 19:25, Tobias Boege wrote:
> On Mon, 02 Mar 2015, John Rose wrote:
>> I have a Click event on a Button. At runtime, clicking the button should
>> cause clearing of the data from a TextArea & some ListBoxes. There's no
>> way this 'clearance' cannot be executed as the Exec of a CL program
>> (which definitely happens because it populates these controls) soon
>> follows it. However, it doesn't seem to do so. Clearance coding:
>> With StopListBox
>> .Clear
>> .Refresh
>> End With
>> With SteckersListBox
>> .Clear
>> .Refresh
>> End With
>> With ReflectorListBox
>> .Clear
>> .Refresh
>> End With
>> With RotorsListBox
>> .Clear
>> .Refresh
>> End With
>> With DetailTextArea
>> .Clear
>> .Refresh
>> End With
>>
>> Is the above the correct method of causing the clearance to happen on
>> the screen immediately?
>>
> That last word is important. Controls are refreshed during the event loop
> which you can think of as the pause mode of the interpreter: it enters it
> when there is no Gambas code to execute at present. The interpreter sits
> there waiting for events to happen or does maintenance like redrawing the
> GUI.
>
> You can force the interpreter to look at pending events (and to redraw the
> controls by the way!) by using the Wait instruction without argument.
> Calling Refresh() is not necessary here which saves you 3 lines per Clear()
> call.
>
> Regards,
> Tobi
>
More information about the User
mailing list