• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: What's the difference in these?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What's the difference in these?


  • Subject: Re: What's the difference in these?
  • From: Phil Stokes <email@hidden>
  • Date: Mon, 04 Apr 2016 14:05:34 +0700


On 4 Apr 2016, at 12:57, Brian Christmas <email@hidden> wrote:
It’s going to be a PITA to re-write the code

I’m not sure what you’re trying to do, but buttons are for getting information from users (primarily, finding out what they want to do); it doesn’t make sense for you to try to GUI script your own app in order to call your own code. 

If you need to call the action method that a button normally calls, you do that from within the code itself. In Cocoa-ObjC (sorry, you’ll have to translate into ASObjc) a method like 

- (IBAction)listBtn:(id)sender 

could be called from within the same class with

[self listBtn: nil];

That assumes that you don’t actually need info from the sender and that the receiver will accept a nil value (it will, unless you’ve specified otherwise in the receiver’s code). 

If you need to send a value, then you’ll have to wrap that in an appropriate object e.g., if you need to send an integer you’ll have to wrap it in an NSNumber object. Also, you’ll need to make sure that the receiver knows how to handle that object. So, suppose my button normally sends a tag and my receiver normally deals with it thus:

- (IBAction)listBtn:(id)sender 
{

int i = [sender tag]

//rest of the method

}

then I’ll have to modify it to handle the possibility that it’s being called in code and I’m sending (for example) an int wrapped in an NSNumber object:

- (IBAction)listBtn:(id)sender 
{

int i; 

if ([sender isKindOfClass:[NSNumber class]]) 
{

i = [sender integerValue];

} else {

i = [sender tag];

}

//rest of the method
}



Best



Phil




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >What's the difference in these? (From: Brian Christmas <email@hidden>)
 >Re: What's the difference in these? (From: Shane Stanley <email@hidden>)
 >Re: What's the difference in these? (From: Brian Christmas <email@hidden>)

  • Prev by Date: Re: What's the difference in these?
  • Next by Date: Re: What's the difference in these?
  • Previous by thread: Re: What's the difference in these?
  • Next by thread: Re: What's the difference in these?
  • Index(es):
    • Date
    • Thread