Re: How can I "highlight" user interface objects? (Final answer I hope...)
Re: How can I "highlight" user interface objects? (Final answer I hope...)
- Subject: Re: How can I "highlight" user interface objects? (Final answer I hope...)
- From: Jerry LeVan <email@hidden>
- Date: Sun, 17 Nov 2002 10:46:14 -0500
This change seems to do what I want for a temporary highlight with a "fat"
pen.
- (IBAction)colorAction:(id)sender
{
NSLog(@"Clicked Button");
[box lockFocus]; // box is a ui element we want to highlight
NSRect theFrame = [box bounds];
[[NSColor blueColor] set];
NSBezierPath *thePath = [NSBezierPath bezierPathWithRect:theFrame];
[thePath setLineWidth:5];
[thePath stroke];
[box unlockFocus];
}
--Jerry
>
Ha,
>
I guess I was getting warm, after about 12 hours of experimentation I
>
found
>
that the following seems to do the job.
>
- (IBAction)colorAction:(id)sender
>
{
>
NSLog(@"Clicked Button");
>
[box lockFocus];
>
NSRect theFrame = [box bounds];
>
[[NSColor redColor] set];
>
[NSBezierPath strokeRect:theFrame];
>
[box unlockFocus];
>
}
>
>
- (IBAction)unColorAction:(id)sender
>
{
>
[box setNeedsDisplay:YES];
>
}
>
Ie a red outline is placed around the ui element pointed to by box. I
>
tested
>
a textfield, tableview, and textview. For the latter two you need to be
>
careful and choose the enclosing scrollview. The highlighting persists
>
until
>
the ui needs to be redrawn.
>
>
Now I have to figure out how to fatten the pen...
>
>
Is this technique supposed to be obvious?
>
>
--Jerry
>
>
Message: 13
>
Date: Sat, 16 Nov 2002 11:46:26 -0500
>
Subject: How can I "highlight" user interface objects?
>
From: Jerry LeVan <email@hidden>
>
To: <email@hidden>
>
>
Hi,
>
>
I am trying to add some "spit and polish" to my *first* Cocoa
>
application, a
>
CSV file editor.
>
>
I want to drag a file using the Finder onto my open application and
use
>
the
>
supplied file to view in the application. ( It is a single window
>
application).
>
>
Any way, before I attempt to implement the dragging destinations stuff
I
>
thought I would try to determine how to draw a green/blue/whatever
>
rectangle
>
around a user interface object.
>
>
I built a small app with a text scrollview ,a colorit button and an
>
uncolorit button.
>
>
I had hoped to press the colorit button and have the frame of the
>
scrollview
>
rendered as a red rectangle, the uncolorit button is supposed to undo
>
the
>
damage.
>
>
I thought something like this might help:
>
- (IBAction)colorAction:(id)sender
>
{
>
NSRect bounds = [scrollViewWindow frame];
>
>
[[NSColor redColor] set];
>
[NSBezierPath strokeRect:bounds];
>
>
}
>
>
Of course nothing(visible) happens when the button action is
invoked...
>
>
Any suggestions?
>
>
Thanks,
>
>
Jerry
>
>
-- __--__--
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.