Re: How can I "highlight" user interface objects?
Re: How can I "highlight" user interface objects?
- Subject: Re: How can I "highlight" user interface objects?
- From: Brock Brandenberg <email@hidden>
- Date: Sun, 17 Nov 2002 10:31:59 -0600
Hi Jerry.
>
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.
>
>
Any suggestions?
Basically, inside a drawRect: method, you save the graphics state, turn on
the NSSetFocusRingStyle() for the current graphics state, draw what you want
to be highlighted, then restore the old graphics state to effectively turn
off the focus ring drawing. This highlighting works very much like the
shadow trick from Core Graphics (search for ShadowView on Cocoa Dev Central)
in that it is a property of the graphics state. Also look at the NSView
method setKeyboardFocusRingNeedsDisplayInRect: which will take your current
dirty display rect and expand it for you to encompass the rect that the
focus ring will need for drawing, saving you the work of guessing and
calculating.
I am only learning and adding these touches to my UI now, but this is the
"proper" way to do UI focus highlighting.
Brock Brandenberg
----- industrial design @ www.bergdesign.com ------
_______________________________________________
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.