{"id":750,"date":"2011-09-06T09:51:53","date_gmt":"2011-09-05T21:51:53","guid":{"rendered":"https:\/\/www.deltics.co.nz\/blog\/?p=750"},"modified":"2011-09-06T09:57:02","modified_gmt":"2011-09-05T21:57:02","slug":"xe2-firemonkey-designer-clipboard-niggles","status":"publish","type":"post","link":"https:\/\/www.deltics.co.nz\/blog\/posts\/750\/","title":{"rendered":"XE2 FireMonkey Designer &#8211; Clipboard Gotcha"},"content":{"rendered":"<span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">[Estimated Reading Time: <\/span> <span class=\"rt-time\">4<\/span> <span class=\"rt-label rt-postfix\">minutes]<\/span><\/span><p>We are still waiting for our XE2 licenses to be organised but in the meantime I have started playing around with the <a href=\"https:\/\/downloads.embarcadero.com\/free\/delphi\">Free Trial Edition<\/a>.  I haven&#8217;t had much time to form much of an opinion as yet, but have already identified some oddities in the FireMonkey Form Designer, specifically in the area of clipboard support.<br \/>\n<!--more--><br \/>\nAt first I thought the clipboard was completely broken in the FireMonkey designer.<\/p>\n<p>If I created a new FireMonkey application and dropped a few controls on a form and then tried to copy\/paste those controls I simply couldn&#8217;t.  The Cut\/Copy options on the Edit menu were disabled and the keyboard shortcuts didn&#8217;t work.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/Screen-Shot-2011-09-06-at-9.24.22-AM.png?resize=398%2C256&#038;ssl=1\" alt=\"Cut\/Copy Disabled\" title=\"Cut\/Copy Disabled\" width=\"398\" height=\"256\" class=\"aligncenter size-full wp-image-752\" srcset=\"https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/Screen-Shot-2011-09-06-at-9.24.22-AM.png?w=398&amp;ssl=1 398w, https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/Screen-Shot-2011-09-06-at-9.24.22-AM.png?resize=300%2C192&amp;ssl=1 300w\" sizes=\"(max-width: 398px) 100vw, 398px\" data-recalc-dims=\"1\" \/><\/p>\n<p>I immediately tried the same thing in the VCL form designer and found that everything was working as expected.  What was going on?<\/p>\n<p>Responses to a Google+ post on the issue varied from those who saw the same thing and those who had no problems, all using the same XE2 build but with a variety of VM solutions.  Eventually these responses pointed me in the direction of the Structure View&#8230; sure enough, I could Cut\/Copy if I first selected the item I wished to Cut\/Copy in the Structure View directly.  Having done that, the Form Designer itself then also became &#8220;enabled&#8221; for Cut\/Copy operations.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/Screen-Shot-2011-09-06-at-9.45.58-AM.png?resize=345%2C240&#038;ssl=1\" alt=\"Cut\/Copy Enabled - Structure View\" title=\"Cut\/Copy Enabled - Structure View\" width=\"345\" height=\"240\" class=\"aligncenter size-full wp-image-753\" srcset=\"https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/Screen-Shot-2011-09-06-at-9.45.58-AM.png?w=345&amp;ssl=1 345w, https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/Screen-Shot-2011-09-06-at-9.45.58-AM.png?resize=300%2C208&amp;ssl=1 300w\" sizes=\"(max-width: 345px) 100vw, 345px\" data-recalc-dims=\"1\" \/><\/p>\n<p>This then raised a quirk in behaviour in the FireMonkey designer &#8220;Paste&#8221; operation which probably should be resolved.  To understand this quirk though, let us quickly remind ourselves how the VCL designer has always worked:<\/p>\n<p>In the VCL designer if you copy a control and then paste it back into the form, the new instance becomes selected by default.  This is <strong>A Good Thing<\/strong> &#8211; you almost certainly want to change some properties on the new, pasted instance.  If you then paste more instances, the freshly pasted control is the &#8220;paste context&#8221;.  More often than not this isn&#8217;t important &#8211; most VCL controls cannot act as containers for other controls, so if you paste a <strong>TButton<\/strong> and then paste another <strong>TButton<\/strong>, the designer cannot paste it into the selected <strong>TButton<\/strong> and so the new instance is pasted into the selected button&#8217;s container.<\/p>\n<p>This can be easily seen in action:<\/p>\n<ul>\n<li>Place a <strong>TPanel<\/strong> on a VCL form<\/li>\n<li>Place a <strong>TButton<\/strong> in that panel<\/li>\n<li>Select and copy the button<\/li>\n<li>Paste the button<\/li>\n<\/ul>\n<p>The new button instance is selected by default<\/p>\n<ul>\n<li>Paste again<\/li>\n<\/ul>\n<p>Another new button is pasted with the <strong>TPanel<\/strong> as it&#8217;s parent.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/Screen-Shot-2011-09-06-at-9.49.09-AM.png?resize=525%2C385&#038;ssl=1\" alt=\"Pasting Buttons in the VCL Designer\" title=\"Pasting Buttons in the VCL Designer\" width=\"525\" height=\"385\" class=\"aligncenter size-full wp-image-754\" srcset=\"https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/Screen-Shot-2011-09-06-at-9.49.09-AM.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/Screen-Shot-2011-09-06-at-9.49.09-AM.png?resize=300%2C220&amp;ssl=1 300w\" sizes=\"(max-width: 525px) 100vw, 525px\" data-recalc-dims=\"1\" \/><\/p>\n<p>When you try to paste into a control that cannot act as a container, the VCL designer try to find the nearest parent that can act as a container and pastes into that.<\/p>\n<p>Now repeat the same steps in the FireMonkey designer:<\/p>\n<ul>\n<li>Place a TPanel on a FireMonkey form<\/li>\n<li>Place a TButton in that panel<\/li>\n<li>Select and copy the button<\/li>\n<li>Paste the button<\/li>\n<\/ul>\n<p>(NOTE: In my case, in order to be able to &#8220;Paste&#8221; I had to first click away from the button, de-selecting it, then click it again in the Structure View to select it once more)<\/p>\n<p>The new button instance is selected by default &#8211; exactly the same as the VCL designer but the parent of the new button is the original button, NOT the panel!<\/p>\n<ul>\n<li>Paste again<\/li>\n<\/ul>\n<p>Another new button is pasted but this time the previously pasted button is the parent.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/Screen-Shot-2011-09-06-at-9.48.39-AM.png?resize=489%2C373&#038;ssl=1\" alt=\"Pasting Buttons - FireMonkey\" title=\"Pasting Buttons - FireMonkey\" width=\"489\" height=\"373\" class=\"aligncenter size-full wp-image-755\" srcset=\"https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/Screen-Shot-2011-09-06-at-9.48.39-AM.png?w=489&amp;ssl=1 489w, https:\/\/i0.wp.com\/www.deltics.co.nz\/blog\/wp-content\/uploads\/Screen-Shot-2011-09-06-at-9.48.39-AM.png?resize=300%2C228&amp;ssl=1 300w\" sizes=\"(max-width: 489px) 100vw, 489px\" data-recalc-dims=\"1\" \/><\/p>\n<p>Crucially this isn&#8217;t immediately apparent because the nature of &#8220;parenting&#8221; in FireMonkey is quite different from that in the VCL &#8211; a parent control does not &#8220;clip&#8221; it&#8217;s children (in the examples I have found so far &#8211; there may be exceptions).  So visually there is nothing to tell you that the pasted buttons are parented by anything other than the panel &#8211; unless and until you move the &#8220;root&#8221; button, at which point the other &#8220;child&#8221; buttons will move also as their positions are relative to their parent, obviously.<\/p>\n<p>This at first appears to be a bug, but I think it&#8217;s more accurate to say it&#8217;s an oversight.  The behaviour (apart from the initial clipboard bug) is essentially the same as that of the VCL designer.  The difference is that any FireMonkey control can be the parent of any other FireMonkey control, so the consequences of assuming the selected control as the &#8220;paste context&#8221; and default selection of any newly pasted control combine to create the potential for unintentional nesting.<\/p>\n<h2>Suggested Fix\/Change in Behaviour<\/h2>\n<p>Given that the &#8220;Parent\/Child&#8221; relationship in FireMonkey is so different, I think the &#8220;Parent&#8221; property of any pasted control should respect and reflect the Parent property on the original Copy (or Cut) control.  That is, if you paste a Control whose parent is &#8220;A&#8221; then it should be pasted with a parent of &#8220;A&#8221;.  A &#8220;Shift&#8221; key modifier could be used to instruct the form designer to ignore the Parent property on the clipboard and instead paste into the currently selected control.<\/p>\n<p>But in the meantime, this is something to be aware of when copy\/pasting in the FireMonkey form designer.<\/p>\n","protected":false},"excerpt":{"rendered":"<p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">[Estimated Reading Time: <\/span> <span class=\"rt-time\">4<\/span> <span class=\"rt-label rt-postfix\">minutes]<\/span><\/span> We are still waiting for our XE2 licenses to be organised but in the meantime I have started playing around with the Free Trial Edition. I haven&#8217;t had much time to form much of an opinion as yet, but have already identified some oddities in the FireMonkey Form Designer, specifically in the area of clipboard [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":[]},"categories":[4],"tags":[140],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1TKYv-c6","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":1068,"url":"https:\/\/www.deltics.co.nz\/blog\/posts\/1068\/","url_meta":{"origin":750,"position":0},"title":"Info From the World Tour (Hamburg)","date":"22 Aug 2012","format":false,"excerpt":"In the Embarcadero forums, Roland Kossow posted his report on the first of the \"RAD Studio World Tour\" events in Hamburg yesterday, reporting on what's new in XE3 and adding some more detail to the \"XE3 And Beyond\" blog post. In a nutshell we have \"FM2\" (FireMonkey 2 - no\u2026","rel":"","context":"In &quot;Delphi&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":791,"url":"https:\/\/www.deltics.co.nz\/blog\/posts\/791\/","url_meta":{"origin":750,"position":1},"title":"Why Does My OSX FireMonkey App Think It Is a Console App ?","date":"15 Sep 2011","format":false,"excerpt":"Because System.IsConsole is hardwired to TRUE on MAC OS: This is actually also the case for $ifdef LINUX, but nobody is likely to notice that, at least not just yet. :) But it caused me no end of confusion when my FireMonkey app behaved one way on Windows and a\u2026","rel":"","context":"In &quot;Delphi&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":795,"url":"https:\/\/www.deltics.co.nz\/blog\/posts\/795\/","url_meta":{"origin":750,"position":2},"title":"When Does &#8220;CreateForm&#8221; Not Create a Form&#8230; ?","date":"15 Sep 2011","format":false,"excerpt":"Apparently, when your application is a FireMonkey application. If you have any applications which contain code similar to this: Then you will need to rethink how you initialise those forms in the FireMonkey framework because CreateForm() commits what I consider to be a cardinal sin (in the software development world\u2026","rel":"","context":"In &quot;Delphi&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":843,"url":"https:\/\/www.deltics.co.nz\/blog\/posts\/843\/","url_meta":{"origin":750,"position":3},"title":"XE2 Update #4 On The Horizon","date":"19 Jan 2012","format":false,"excerpt":"The release notes for Update #4 have appeared online, signalling the imminent arrival no doubt of the update itself. The good news if you are using FireMonkey is that this is a significant update, including functionality for printing. The bad news is that like update #1, this update is not\u2026","rel":"","context":"In &quot;Delphi&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":735,"url":"https:\/\/www.deltics.co.nz\/blog\/posts\/735\/","url_meta":{"origin":750,"position":4},"title":"RAD STUDIO XE2: Launch Event Report","date":"04 Aug 2011","format":false,"excerpt":"Today I was fortunate to be present in Auckland at the World Premier of the launch event for RAD Studio XE2. \u00a0There is so much good to report that I really don't know where to begin, so apologies if this post is a bit of a disorganised ramble. \u00a0But here\u2026","rel":"","context":"In &quot;Delphi&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":936,"url":"https:\/\/www.deltics.co.nz\/blog\/posts\/936\/","url_meta":{"origin":750,"position":5},"title":"A Pain In The Butt","date":"31 Jul 2012","format":false,"excerpt":"This post is one of those classic double-entendres for which us Brits are (in)famous, involving as it does both an actual Pain In The Butt and a euphemistic one. I have been incapacitated recently by a sudden onset of sciatica caused - so my physio seems to think - by\u2026","rel":"","context":"In &quot;Delphi&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.deltics.co.nz\/blog\/wp-json\/wp\/v2\/posts\/750"}],"collection":[{"href":"https:\/\/www.deltics.co.nz\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.deltics.co.nz\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.deltics.co.nz\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.deltics.co.nz\/blog\/wp-json\/wp\/v2\/comments?post=750"}],"version-history":[{"count":5,"href":"https:\/\/www.deltics.co.nz\/blog\/wp-json\/wp\/v2\/posts\/750\/revisions"}],"predecessor-version":[{"id":758,"href":"https:\/\/www.deltics.co.nz\/blog\/wp-json\/wp\/v2\/posts\/750\/revisions\/758"}],"wp:attachment":[{"href":"https:\/\/www.deltics.co.nz\/blog\/wp-json\/wp\/v2\/media?parent=750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.deltics.co.nz\/blog\/wp-json\/wp\/v2\/categories?post=750"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.deltics.co.nz\/blog\/wp-json\/wp\/v2\/tags?post=750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}