Java NSViews Using Clear Colors
Java NSViews Using Clear Colors
- Subject: Java NSViews Using Clear Colors
- From: Jack <email@hidden>
- Date: Mon, 7 Feb 2005 12:08:07 +0000
Developers,
I have tried so many different approaches I have none left up my sleeve.
The idea is that I want to track mouse views by drawing a vertical and horizontal line whenever they cross. To do this I use a NSView subclass called MouseTrackView.
The problem is that the view does not get painted fresh, partly because I have filled the rect in drawRect() with a clearColor. Filling it with any other color achieves the objective, but it has to be transparent so that the views below it are visible.
ie
public void drawRect(NSRect aRect){
try{
NSGraphicsContext.saveGraphicsContext();
//NSColor.whiteColor().set();
//NSBezierPath.fillRect(aRect);
NSColor.clearColor().set();
NSBezierPath.fillRect(aRect);
NSWindow window = window();
window.setAcceptsMouseMovedEvents(true);
//NOW DRAW
When white color is set it works fine. But when clearColor is set the view is not fresh on each redisplay.
DummyView is meant to model a view which is very expensive to draw - so every mouse move cannot ask for the view to be redrawn.
If i could get mouseTrackView to redraw after each mouseMove without getting the views below it to draw then that would be brilliant.
I have made no progress this weekend, becuase of this problem.
I tried using
replaceSubview().
I also tried overriding setNeedsDisplay,
setNeccessaryToDraw() ,
display(), needsToDrawRect(NSRect aRect). None of these worked.
Please somebody have a look - I am really stuck.
Many Thanks
Jack
_______________________________________________
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