Let me elaborate the steps i am doing
- Create Mac 10.9 Project
- Drag a CustomView (Let's call it myView) to the .xib
- Drag a NSButton to the .xib but out side the CustomView
Now programatically (using a other class) i add a NSTextField to the CustomView when the button is clicked by this code
NSTextField *textField = [[NSTextField alloc] init]; [textField setBezeled:NO]; [textField setEditable:NO]; [textField setSelectable:NO]; [textField setFont:[NSFont fontWithName:@"Arial" size:20]]; [textField setStringValue:@"Hello World!"]; int textWidth = textField.fittingSize.width; int textHeight = textField.fittingSize.height; [textField setFrame:NSMakeRect(0, 0, textWidth, textHeight)]; [myView addSubview:textField];
Now i see that the TestField is added to myView
- All i want is the user can drag the textField movable inside myView
i added the following code
- (void)mouseDown:(NSEvent *)event{
NSLog(@"Hi");
}
But the NSLog is not getting shown
How do i make the NSTextField draggable?