Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 5    Views: 72

NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
09/27/14 10:43 AM (9 years ago)

Button Method with Ultimate Screen Creator

USC has nime button actions available via the control panel. However adding a general purpose method call would be great. Currently I have re-purposed one of the available USC Button Actions to hard code a method action. (and imported the .h) What would be great is a new Button Action "Call Method" added to the Plugin, which would be available from the Control Panel. The text entered would be the objectname and methodname. For example: [KM_MyObjectName myMethodName]; (experimenting with Kitty new snow plugin I used: [AK_SnowView hideSnow]; ) Chris- If you a few minutes this would be an awesome addition for users of USC. Thanks!
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
09/27/14 11:01 AM (9 years ago)
Shameless plug the Mosaic has 3 custom actions you could hard code. It's an interesting notion though you can defo do class from string not sure about method from string
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
09/27/14 11:02 AM (9 years ago)
Plus you want a toggle method for the hide and show might add that
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
09/27/14 11:20 AM (9 years ago)
Method from a string is definitely possible - at least in Obj-C (I think Swift breaks this and other related approaches, which is problematic for Buzztouch). To do so you would do something like this: NSString *methodName = [BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"methodName" defaultValue:@""]; if (methodName.length>0) { SEL thisMethod = NSSelectorFromString(methodName); if ([self respondsToSelector:thisMethod]) [self performSelectorOnMainThread:thisMethod withObject:nil waitUntilDone:NO]; } If you need to pass in an object, you can do so (but only one object). However, I don't plan on adding this capability to the USC plugin. It's way too complicated for most people to understand, and would cause too much support on my part for people that email and say "hey, I used the custom method function on a button and it broke my app".
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
09/27/14 11:37 AM (9 years ago)
Just updated the Snow View you can now toggle the snow call [AK_SnowView toggleSnow]; saves you writing any logic
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
09/27/14 01:50 PM (9 years ago)
Chris- OK I understand that it could generate support issues, so how about this… 1. Add three Button Actions (i.e. custom1, custom2, and custom3) accessible via BT Control Panel 2. Code added to CR_ultimatScreenCreator.m else if ([elementButtonAction isEqualToString:@"custom1"]) { // Add Custom code here } else if ([elementButtonAction isEqualToString:@"custom2"]) { // Add Custom code here } else if ([elementButtonAction isEqualToString:@"custom3"]) { // Add Custom code here } ===== Add a statement that these three are meant for more advance users who will be adding their own code in Xcode. Up to developer what we put in there, but makes it super easy to expand functionality of buttons on USC without you supporting any code developer adds ;)
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.