Skip navigation.
 
mlRe: How to create a button dynamically and set action in subclass
FROM : Anish Kumar
DATE : Thu Dec 09 06:28:45 2004

Hi,

I re-checked my sent mail folder for the TO: address and it was indeed addressed to JOHN
FOX and I wonder how John Spicer, recevied it.

Any way thanks once again for JOHN FOX for the help.

-Anish


On Tue, 07 Dec 2004 John Spicer wrote :
>I think you sent this to the wrong john!
>
>On Dec 7, 2004, at 4:38 AM, Anish Kumar wrote:
>

>>    Hi John,
>>
>>  Thanks for your much needed help. I used your suggestion and was able  to find a

solution
>>  for my problem.
>>
>>  I created a new nib file and added a button over window(a borderless  window). Then I
>>  changed the fileowners class as sub-class of NSWindow.  In the  application when the

user
>>  writes his comments for the image and saves it, I attach the new  button window as a
child
>>  window to the window that display the image. So every time a user  comments and
saves it,
>>  a button will sit over the original image indicating that there is a  comment. Now if the
user
>>  clicks the button, I open a new window and display the comment that  was stored for
that
>>  location.
>>
>>  Thanks once again John for your help,
>>  -Anish,
>>  http://indinfo.webpulsar.com/
>>
>>
>>  On Mon, 06 Dec 2004 John Fox wrote :
>>  >Hi Anish:
>>  >
>>  >I've done something similar, by using a "prototype" view that I  instantiate from a nib

file
>>  and which is then positioned on screen over an NSImageView subclass.  It's not terribly
>>  difficult to do, and since I've gotten lots of help from people on  the list at various

times, I'd
>>  be happy to help you with it.
>>  >
>>  >Essentially, in IB you want to create your view object with whatever  UI elements you

need
>>  (a scrolling text field and/or a button, etc.). In that nib file: I  suggest you create your
own
>>  subclass to be the File's Owner. This will make it possible to take  care of loading the
nib
>>  file, take care of whatever configuration you need, etc. The File's  Owner will also
contain the
>>  action methods you need for when a button is clicked, etc.
>>  >
>>  >To load the nib file, you use something like this in your class'  init method:
>>  >
>>  >      [NSBundle loadNibNamed: @"MyNiftyNibFile" owner: self];
>>  >
>>  >You'll want to make add this view to your NSImageView subclass by  doing something

like:
>>  >
>>  >  if (![[myImageView subviews] containsObject:mySubview])
>>  >  {
>>  >      [myImageView addSubview:mySubview];
>>  >  }
>>  >
>>  >You will also need to set the location, and possibly adjust the size  of this view using
>>  NSView's setFrameOrigin: and setFrameSize: methods.
>>  >
>>  >Doubtless, there may be other approaches to solve this problem, but  this technique

has
>>  worked well for me.
>>  >
>>  >Anyway, I hope this helps, and If not, feel free to get in touch,  and I'll see if I can help

you
>>  some more.
>>  >
>>  >Take care,
>>  >
>>  >John
>>
>>
>>  <inbox.gif> _______________________________________________
>>Do not post admin requests to the list. They will be ignored.
>>Cocoa-dev mailing list      (<email_removed>)
>>Help/Unsubscribe/Update your Subscription:
>>http://lists.apple.com/mailman/options/cocoa-dev/ <email_removed>
>>
>>This email sent to <email_removed>

Related mailsAuthorDate
No related mails found.