A way to access the parent of a control #950
Replies: 2 comments 1 reply
-
Yes this would be very much helpful I also got into this problem and @ndonkoHenri helped. It would have certainly be much easier to wrap my head around it if I could just access the current control's parent. |
Beta Was this translation helpful? Give feedback.
-
It won't be hard to add |
Beta Was this translation helpful? Give feedback.
-
@FeodorFitsner, what do you think of adding a way to access the parent of a control?
I thought of this idea because alot of guys have been asking how to delete an item from a
ListView
(ListTile
) when a button/Control in the tile is pressed.The way I solve this issue was to always add a reference to the tile in the
data
property of theControl
which will be used to delete the tile... and when the required event happens, grab thee.control.data
(the ref), andremove
it from theListView.controls
list. Nevertheless, I think a better, efficient, and alternative approach could be to access the parent of that Controle.control.parent
(the ref), andremove
it from theListView.controls
list.Why could this be useful?
Using references could become an issue or fail when the
Control
keeping that reference is moved elsewhere. Whereas, using the.parent
is cleaner and will never fail, because when theControl
we need is moved any where, it's.parent
is changed to its new parent.I maybe poorly explained my thoughts, but
.parent
could be used in many other areas.Let me know what you think of this.
I just had the idea, but don't even know if it will be possible to implement :)
Beta Was this translation helpful? Give feedback.
All reactions