Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Creating Custom UI Elements

Creating Custom UI Elements
Thread Tools
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Jun 17, 2001, 03:10 PM
 
Does any one know of an example that illustrates overriding a UI widget's default draw method? For example, say you want to create an audio equalizer but you do not want to use the default sliders because they have a boring shape. Instead you want it to have a cloud shaped handle and the tick marks should be little lightning bolts as opposed to straight line segments. It's a bit of a stretch, but it illustrates the point.

I am sure there is a way of pulling this off but I have no idea how to do it and how much work is involved. Also, It would be nice to have the ability to add it to an IB palette. Can you imagine, this way you could have an infinite repertoire of UI elements
iMac 17" G4 800MHZ & 768 SDRAM
     
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status: Offline
Reply With Quote
Jun 17, 2001, 06:39 PM
 
Usually it says what methods to override to do what you want. For example: If you want a SliderCell to draw a totally different track, then you can subclass NSSliderCell and override the - (void)drawWithFrame NSRect)aRect inView NSView*)aView method. Remember to call [super drawKnob]; when you are done in order to make sure that it draws the knob. Want it to draw it's own bar and then let you draw over it? Then override the - (void)drawBarInside NSRect)aRect flipped BOOL)flipped method and draw over it.

I used these methods to make a custom slider. Problem? The - (void)drawWithFrame NSRect)aRect inView NSView*)aView method is undocumented, and nobody would expect that if you overrode the - (void)drawBarInside NSRect)aRect flipped BOOL)flipped that the slider would draw it's own bar anyway; it makes no sense from the documentation.

Advice: if you want to do custom drawing in standard widgets, then read the documentation and if it appears to be wrong then look in the headers and see what might be good to override.

[ 06-17-2001: Message edited by: Dalgo ]
     
DaGuy  (op)
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Jun 18, 2001, 07:05 PM
 
Thanks very much for the information and the tips. At least now I have some ideas about what next steps are. Hopefully I will be able to create some cool mutant sliders in the near future
iMac 17" G4 800MHZ & 768 SDRAM
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:52 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2