Hi, i have this code in MyButton.m, subclass of NSButton.
If i call the changeStringValue IBAction everything goes fine, but nothing happens hovering the NSButton associated with the MyButton class, it only shows the NSLog "ENTER" message but myTextField stringvalue isn't updated and the "label:" nslog says NULL.
Does anyone have a clue?
Edit:
I've inserted [self performSelectorOnMainThread
selector(changeStringValue: ) withObject:myTextField waitUntilDone:YES]; inside the mouseEnter: event and NSLog(@"Running"); inside the changeStringValue function: now hovering the button i call the function (i see the "running" log) but nothing happens. The function, as a Sent Action assigned to a button, is still working. I've also tried with waitUntilDone:YES/NO and withObject:myTextField/self but it's the same.
Code:
-(void)updateTrackingAreas{
if (trackingArea){
[self removeTrackingArea:trackingArea];
}
NSTrackingAreaOptions options = NSTrackingInVisibleRect | NSTrackingMouseEnteredAndExited | NSTrackingActiveInKeyWindow;
trackingArea = [[NSTrackingArea alloc] initWithRect:NSZeroRect options:options owner:self userInfo:nil];
[self addTrackingArea:trackingArea];
}
-(void)mouseEntered:(NSEvent *)theEvent{
NSLog(@"ENTER");
[myTextField setStringValue:@"Foo"];
NSLog(@"label: %@", myTextField.stringValue);
}
-(IBAction)changeStringValue:(id)sender{
[myTextField setStringValue:@"Foo"];
}
If i call the changeStringValue IBAction everything goes fine, but nothing happens hovering the NSButton associated with the MyButton class, it only shows the NSLog "ENTER" message but myTextField stringvalue isn't updated and the "label:" nslog says NULL.
Does anyone have a clue?
Edit:
I've inserted [self performSelectorOnMainThread
Last edited: