Skip to content

Passing viewables between windows #79

Closed Answered by can-lehmann
dlesnoff asked this question in Q&A
Discussion options

You must be logged in to vote

You have 2 options:

  1. RECOMMENDED If you want to share a lot of state, you probably want to use a proper architecture for your app. I recommend using a Model/View architecture, where you have a Model = ref object ... that stores your applications state, and each viewable has a model: Model field which it uses as its "data source". Here is an extremely contrived example of this: #39 (comment)

  2. If you just want to share a small amount of state between the ChangeCounter dialog and the App, you can just read it back once the dialog is closed:

proc clicked() =
  let (res, state) = app.open: gui:
    ChangeCounter()
  app.counter = ChangeCounterState(state).selected

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@can-lehmann
Comment options

Answer selected by dlesnoff
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #78 on September 14, 2023 12:55.