• 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: custom NSView problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: custom NSView problem


  • Subject: Re: custom NSView problem
  • From: Matt Neuburg <email@hidden>
  • Date: Sun, 12 Sep 2004 10:29:29 -0700

On Sat, 11 Sep 2004 13:17:31 +0100, Peter Browne
<email@hidden> said:
>Hi,
>I have a custom NSView, (named targetView) and when the user clicks on
>the window, I want the coordinates of the click to be displayed in an
>NSTextField. Everything works fine, except when mouseDown: is called,
>the NSTextField isn't updated. I don't get any errors, simply nothing
>happens.
>
>This is what I have written so far. 'center' is the NSPoint  initially
>at the center of the window until there is a mouse click, 'currtgt' is
>the outlet name for the NSTextField, and 'tgt' is an NSString. Any
>ideas?
>
>- (void)mouseDown:(NSEvent *)event
>{
>
>     NSPoint eventLocation = [event locationInWindow];
>     center = [self convertPoint:eventLocation fromView:nil];
>     [self setNeedsDisplay:YES];
>
>     NSLog(@"New target designated at coordinates: (%.0f,%.0f)",
>center.x, center.y);
>
>     tgt = NSStringFromPoint(center);
>     [currtgt setStringValue:tgt];
>}

If it all works just fine up to and including the NSLog, but then the
NSTextField does not change, I would have to suggest that, no, currtgt is
*not* the outlet name for the NSTextField - it is a name for nil. Messages
to nil don't generate any error message, but they don't do anything either.
Check your names and your IB outlets. m.

--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>



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

This email sent to email@hidden

  • Prev by Date: Re: Finding the active NSTextField
  • Next by Date: Re: @protected variable access
  • Previous by thread: Re: Finding the active NSTextField
  • Next by thread: Re: custom NSView problem
  • Index(es):
    • Date
    • Thread