Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
How do you generically fill the “of component” socket of an any-component block? - MIT App Inventor Help - MIT App Inventor Community How do you generically fill the “of component” socket of an any-component block? MIT App Inventor Help any-component-blocks Cigogne May 13, 2022, 6:34pm #1 Hi, I created an app with two TimePicker instances. The AI suggested to convert the TimePicker.AfterTimeSet code into an any-component block. There I want to set the TimePicker.Text property but I have to fill the “of component” socket and I can only find TimePicker1 or TimePicker2. From my understanding I would have to fill the socket with the generic TimePicker instance of the any-component but I can’t find it anywhere. yusufcihan May 13, 2022, 6:43pm #2 The "of component" parameter expects a component instance block. These both does the same job: "any component" blocks are mostly used for setting properties for multiple components, if you only want to change property for single component, you can just use the appropriate setter block of the component. If you want to use "any component" block in "any component" event, you can use the "component" parameter which returns the component that the event invoked for. Cigogne May 13, 2022, 6:51pm #3 Ok, thanks, now I found the get(component) function in the Built-In->Variables section. That’s it. yusufcihan May 13, 2022, 6:53pm #4 You can also move your mouse over orange-colored parameters to directly access to parameter. ChrisWard May 13, 2022, 8:23pm #5 Make a Block List of the (identical type) Components to give all of them the same attribute using Any Component. In your case, Any Component may not be appropriate, it's only two Components and I presume that the Text property will not be identical? Cigogne May 15, 2022, 11:36am #6 Thanks for the tip, alas that’s one of the few things which don’t work when using AI on an iPad or likely on any tablet. The others are editing comments and viewing the contents or deleting items from the backpack. Cigogne May 15, 2022, 12:41pm #7 What do you mean with “Make a Block List”, something like this? image968×104 19.6 KB Though it may not have been the most appropriate solution in this case there are three things to consider. First, using a different approach the question would have come up again on the next occasion. Second, generic code like the AI any components improves the code clarity and from my even short experience that especially important with larger projects in AI2. Third, I prefer generic code over copying and adapting code blocks as that is prone to introduce errors in form of typos as well as changes not being applied to all places. That’s why I put text strings like database tags into constants instead of typing them into each getValue/setValue instance and this leads to another issue with AI: Running the Code Cleanup my global variable definitions I intentionally had placed on top of the workspace partially were dispersed between the other blocks. What I’ missing is something which could be named syntactic sugar. Either the Code Cleanup function should collect code blocks with respect to their type, i.e. all global variables, event handlers, procedures together on different spaces of the workspace. Or there should be special blocks only affecting the arrangement of the top level blocks on screen, so that you could group them together unaffected by the cleanup function. Apart from that it really is impressive what I could achieve with AI2 in just two days of coding, starting from scratch with the Framework as well as app development in general. 1 Like ChrisWard May 15, 2022, 1:52pm #8 Cigogne: What do you mean with “Make a Block List”, something like this? Yes, exactly that - especially useful if several attributes need to be set as identical for all components in the List. ChrisWard May 15, 2022, 1:54pm #9 Cigogne: Running the Code Cleanup my global variable definitions I intentionally had placed on top of the workspace partially were dispersed between the other blocks. That's very odd - I always have my vars at the top of the code and Cleanup has never disrupted that. That said, I always arrange my Blocks in a single column. Cigogne May 15, 2022, 4:42pm #10 Me too left them that way - more or less -exactly because I feared the autumated cleanup happily would mix them if I didn’t. But I would prefer to have a column each for global vars, procedures, event handlers and anything else if I missed something. The automated cleanup could do that but I think special block grouping containers, like I mentioned in the previous post, have a strong advantage: when you extend one block the corresponding slot in the grouping container would expand automatically. That means no overlapping blocks anymore - without having to invoke the cleanup function. ChrisWard May 17, 2022, 10:08am #11 Cigogne: The automated cleanup could do that but I think special block grouping containers This was once achieved in a student project, but in the end was not incorporated by MIT. I think code containers, where the App Developer decides which one is for what, would be very beneficial. This kind of change though requires an upheaval of the original interface code and the MIT team just don't have the time available - it is a struggle to keep up with Google's Android changes alone. Home Categories FAQ/Guidelines Terms of Service Privacy Policy Powered by Discourse, best viewed with JavaScript enabled