Unexpected wxSizer::Detach Behavior
Kafrene Trading <[email protected]> Sat, 25 Apr 2026 00:12:17 -0400
| Newsgroups | gmane.comp.lib.wxwindows.general |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail=_4762C604-D3F6-4A2F-81BE-D4593E240D04 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Hello, I=E2=80=99m a bit confused on the intended usage of wxSizer::Detach. The do= cumentation (for the index variant) reads > Detach an item at position index from the sizer without destroying it. Which reads as though =E2=80=9Cit=E2=80=9D refers to item, and item refers = to the wxSizerItem. However, looking at the code for wxSizer::Detach, it is= clear the item is, in fact, deleted. The window or sizer, if the item =E2=80=9Cheld=E2=80=9D one, is not destroy= ed, but the item itself is, which is surprising to me, since items can be m= ore than just windows or sizers. Ultimately this is something of an x-y problem: The actual goal I=E2=80=99d= like to accomplish is being able to remove an item from the sizer, and the= n re-inserting it either immediately or at a later time, maybe hiding it fo= r a while in the latter case. It=E2=80=99s not obvious how to accomplish this, afaics. I=E2=80=99d like t= o preserve any item attributes (size, border, align, etc.) and maintain abs= traction over the underlying kind. I suppose I could check the kind and copy everything manually, but that fee= ls less than ideal to have in application code. Is there a better way to do this rather than copying the sizer item attribu= tes, detaching, creating a new item with those attributes, then inserting? = If not, would a PR for something like this (=E2=80=9CDetach=E2=80=9D, thoug= h maybe by a different name given the different behavior, which accepts a s= izer item and does the detach without deleting the item) make sense? Thank you, Ryan Ogurek --=20 Please read https://www.wxwidgets.org/support/mlhowto.htm before posting. ---=20 You received this message because you are subscribed to the Google Groups "= wx-users" group. To unsubscribe from this group and stop receiving emails from it, send an e= mail to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/wx-users/67= 2E5DE1-E176-4C34-9EAD-20856816BBB3%40gmail.com. --Apple-Mail=_4762C604-D3F6-4A2F-81BE-D4593E240D04 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="UTF-8" <html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset= =3Dutf-8"></head><body style=3D"overflow-wrap: break-word; -webkit-nbsp-mod= e: space; line-break: after-white-space;">Hello,<div><br></div><div>I=E2=80= =99m a bit confused on the intended usage of wxSizer::Detach. The documenta= tion (for the index variant) reads</div><div><span style=3D"caret-color: rg= b(42, 53, 57); color: rgb(42, 53, 57); font-family: -apple-system, BlinkMac= SystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "= Fira Sans", "Droid Sans", "Helvetica Neue", sans-s= erif; font-size: 15.6px; orphans: 2; widows: 2; background-color: rgb(255, = 255, 255);"><br></span></div><div><blockquote type=3D"cite"><span style=3D"= caret-color: rgb(42, 53, 57); color: rgb(42, 53, 57); font-family: -apple-s= ystem, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Ca= ntarell, "Fira Sans", "Droid Sans", "Helvetica Neu= e", sans-serif; font-size: 15.6px; orphans: 2; widows: 2; background-c= olor: rgb(255, 255, 255);">Detach an item at position</span><span style=3D"= caret-color: rgb(42, 53, 57); color: rgb(42, 53, 57); font-family: -apple-s= ystem, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Ca= ntarell, "Fira Sans", "Droid Sans", "Helvetica Neu= e", sans-serif; font-size: 15.6px; orphans: 2; widows: 2; background-c= olor: rgb(255, 255, 255);"> </span><em style=3D"caret-color: rgb(42, 5= 3, 57); color: rgb(42, 53, 57); font-family: -apple-system, BlinkMacSystemF= ont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sa= ns", "Droid Sans", "Helvetica Neue", sans-serif; f= ont-size: 15.6px; orphans: 2; widows: 2; background-color: rgb(255, 255, 25= 5);">index</em><span style=3D"caret-color: rgb(42, 53, 57); color: rgb(42, = 53, 57); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI&quo= t;, Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid S= ans", "Helvetica Neue", sans-serif; font-size: 15.6px; orpha= ns: 2; widows: 2; background-color: rgb(255, 255, 255);"> </span><span= style=3D"caret-color: rgb(42, 53, 57); color: rgb(42, 53, 57); font-family= : -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, = Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Hel= vetica Neue", sans-serif; font-size: 15.6px; orphans: 2; widows: 2; ba= ckground-color: rgb(255, 255, 255);">from the sizer without destroying it.<= /span></blockquote><br></div><div>Which reads as though =E2=80=9Cit=E2=80= =9D refers to item, and item refers to the wxSizerItem. However, looking at= the code for wxSizer::Detach, it is clear the item is, in fact, deleted.</= div><div><br></div><div>The window or sizer, if the item =E2=80=9Cheld=E2= =80=9D one, is not destroyed, but the item itself is, which is surprising t= o me, since items can be more than just windows or sizers.</div><div><br></= div><div>Ultimately this is something of an x-y problem: The actual goal I= =E2=80=99d like to accomplish is being able to remove an item from the size= r, and then re-inserting it either immediately or at a later time, maybe hi= ding it for a while in the latter case.</div><div><br></div><div>It=E2=80= =99s not obvious how to accomplish this, afaics. I=E2=80=99d like to preser= ve any item attributes (size, border, align, etc.) and maintain abstraction= over the underlying kind.</div><div><br></div><div>I suppose I could check= the kind and copy everything manually, but that feels less than ideal to h= ave in application code.</div><div><br></div><div>Is there a better way to = do this rather than copying the sizer item attributes, detaching, creating = a new item with those attributes, then inserting? If not, would a PR for so= mething like this (=E2=80=9CDetach=E2=80=9D, though maybe by a different na= me given the different behavior, which accepts a sizer item and does the de= tach without deleting the item) make sense?</div><div><br></div><div>Thank = you,</div><div>Ryan Ogurek</div></body></html> <p></p> -- <br /> Please read <a href=3D"https://www.wxwidgets.org/support/mlhowto.htm">https= ://www.wxwidgets.org/support/mlhowto.htm</a> before posting.<br /> --- <br /> You received this message because you are subscribed to the Google Groups &= quot;wx-users" group.<br /> To unsubscribe from this group and stop receiving emails from it, send an e= mail to <a href=3D"mailto:[email protected]">wx-users+u= [email protected]</a>.<br /> To view this discussion visit <a href=3D"https://groups.google.com/d/msgid/= wx-users/672E5DE1-E176-4C34-9EAD-20856816BBB3%40gmail.com?utm_medium=3Demai= l&utm_source=3Dfooter">https://groups.google.com/d/msgid/wx-users/672E5DE1-= E176-4C34-9EAD-20856816BBB3%40gmail.com</a>.<br /> --Apple-Mail=_4762C604-D3F6-4A2F-81BE-D4593E240D04--