Skip to content

Copying/templating widgets? #2531

Answered by freakboy3742
eichin asked this question in Q&A
Discussion options

You must be logged in to vote

There's no builtin-mechanism to clone a widget hierarchy at present; but I'm not 100% sure we need one either. As you've noted, the best approach here is likely to refactor the construction code into a function.

A clone mechanism is likely technically possible, but it would require every widget to gain a method to clone its current state. We'd also need to make decisions about whether some properties wouldn't be cloned - for example, should event handlers be cloned? On the one hand, it would be possible to write event handlers that response to where they are in the layout, but the easiest approach is to use a separate handler for every widget. Lastly, we'd need to encourage users to use t…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by eichin
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