Gurpal Rajput
Gurpal Rajput

Reputation: 1

How To Make Mouse Hover on NSControlSegment With Menu Items in Cocoa Mac os development?

I want to have mouse hover on NSSegmentControl with menu items, I know i need to do something in this.

Screen Shot

- (void)mouseDown:(NSEvent *)event
{

}

please guide me , as i am noobs to mac os development.

Upvotes: 0

Views: 93

Answers (1)

Georg Seifert
Georg Seifert

Reputation: 71

You need to activate mouseMove events. One way is by adding tracking rects:

- (void)updateTrackingAreas {
    [super updateTrackingAreas];
    [self addTrackingArea:[[NSTrackingArea alloc] initWithRect:self.frame options:NSTrackingActiveAlways | NSTrackingInVisibleRect | NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved owner:self userInfo:nil]];
}

- (void)mouseEntered:(NSEvent *)theEvent {
    [self updateMenu];
}

- (void)mouseExited:(NSEvent *)theEvent {
    [self updateMenu];
}

- (void)mouseMoved:(NSEvent *)theEvent {
    [self updateMenu];
}

But the UI doesn’t look like a mac app. If it really needs to look like this, maybe you are better off building it in HTML and embed an WebKitView??

Upvotes: 1

Related Questions