summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorvorstenbosch <[email protected]>2020-06-06 00:39:16 +0200
committervorstenbosch <[email protected]>2020-06-06 00:39:16 +0200
commitd219f068879e2c8c2abc11b2ea2411f3e54cb30f (patch)
tree1b933e2f74441f265e2945af70e5b3c355596f41 /examples
parentf9ad173d6a94cde3e28da04498152b19249209af (diff)
Differentiating between UI changes from the main thread and another goroutine
Diffstat (limited to 'examples')
-rw-r--r--examples/updateui.go18
1 files changed, 7 insertions, 11 deletions
diff --git a/examples/updateui.go b/examples/updateui.go
index 3f61238..48aadfd 100644
--- a/examples/updateui.go
+++ b/examples/updateui.go
@@ -81,20 +81,19 @@ func setupUI() {
mainWindow.SetChild(vbContainer)
showMessageButton.OnClicked(func(*ui.Button) {
- // Update the UI using the QueueMain function
- ui.QueueMain(func() {
- messageLabel.SetText(message.Text())
- })
+ // Update the UI directly as it is called from the main thread
+ messageLabel.SetText(message.Text())
})
clearMessageButton.OnClicked(func(*ui.Button) {
- // Update the UI using the QueueMain function
- ui.QueueMain(func() {
- messageLabel.SetText("")
- })
+ // Update the UI directly as it is called from the main thread
+ messageLabel.SetText("")
})
mainWindow.Show()
+
+ // Counting and updating the UI from another goroutine
+ go counter()
}
func counter() {
@@ -112,8 +111,5 @@ func counter() {
func main() {
count = 0
- // Counting and updating the UI from another goroutine
- go counter()
-
ui.Main(setupUI)
}