{"id":784,"date":"2020-06-30T22:14:00","date_gmt":"2020-07-01T04:14:00","guid":{"rendered":"https:\/\/www.great-white-software.com\/blog\/?p=784"},"modified":"2020-06-23T22:15:07","modified_gmt":"2020-06-24T04:15:07","slug":"working-around-things-the-ide-prevents","status":"publish","type":"post","link":"https:\/\/www.great-white-software.com\/blog\/2020\/06\/30\/working-around-things-the-ide-prevents\/","title":{"rendered":"Working around things the IDE prevents"},"content":{"rendered":"\n<p>Sometimes when you want to subclass a control you want to retain the property name the Xojo control uses, but you want to add some custom functionality by putting a computed property in place in your subclass.<\/p>\n\n\n\n<p>In the long run this makes your subclass a better drop in replacement. You dont end up with the case where the superclass has a property named one thing, like Text, and your subclass has a similar property named something else, like Caption.<\/p>\n\n\n\n<p>For some properties the IDE will prevent you from doing this at all. Basically IF the property you want to do this with is named TEXT you cant create a subclass with a computed property named TEXT because the IDE will stop you &#8211; TEXT is a data type and Xojo will stop you from using that name since TEXT is a data type. <\/p>\n\n\n\n<p>Most times you&#8217;re stuck.<\/p>\n\n\n\n<p>Notice I say &#8220;most times&#8221;<\/p>\n\n\n\n<p>There ARE ways to make this work &#8211; but it involves working AROUND the IDE outside of the IDE. And it can be &#8220;fragile&#8221; &#8211; if you do anything that would alter the signature in the IDE it will fix it for you then you have to redo things.<\/p>\n\n\n\n<p>When I have wanted to do this I will name my property something memorable &#8211; often &#8220;Caption&#8221; or something mostly suitable but still not the name I really want. <\/p>\n\n\n\n<p>Then I save as text (xml would also work since its mostly plain text). Then I open my project in a text editor like BBEdit &amp; I find the item I named &#8220;Caption&#8221; and rename it &#8220;Text&#8221;. Save the edited text and now get the IDE to reload the project.<\/p>\n\n\n\n<p>And there&#8217;s my property named &#8220;Text&#8221; as I expect and I can then also edit and fix any code in the getter &amp; setter and the IDE wont fight me.<\/p>\n\n\n\n<p>I&#8217;ve submitted a <a href=\"http:\/\/&lt;feedback:\/\/showreport?report_id=60736&gt;\">feature request<\/a> to make it so that if there is a property on the super class that has the same name as a data type like Text that the IDE permit me to make a computed property on a subclass that shadows that one.<\/p>\n\n\n\n<p>In the mean time this is a workaround.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes when you want to subclass a control you want to retain the property name the Xojo control uses, but you want to add some custom functionality by putting a computed property in place in your subclass. In the long run this makes your subclass a better drop in replacement. You dont end up with &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.great-white-software.com\/blog\/2020\/06\/30\/working-around-things-the-ide-prevents\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Working around things the IDE prevents&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-784","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/784","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/comments?post=784"}],"version-history":[{"count":3,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/784\/revisions"}],"predecessor-version":[{"id":787,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/784\/revisions\/787"}],"wp:attachment":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/media?parent=784"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/categories?post=784"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/tags?post=784"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}