Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Set max chars for Unicode Edit Text control?



On 7/27/04 6:30 PM, Scott Thompson didst favor us with:

>> I never paste codes into IB. When I first started using IB, I was using
>> unique control signatures in every window. Then I figured out I can use 0 and
>> life with IB has been ever so much easier since.
>
> I use the four character code portion of the control signatures to
> locate controls in the UI using HIViewFindByID (or the older
> GetControlByID). Out of curiosity, if you don't use the same
> mechanism, how do you get ahold of a control in one of your windows to
> initialize it's values after loading it from a NIB?

Strictly speaking you use their ControlIDs to locate controls. A ControlID
is a { signature, id } pair. I see a lot of people using unique values for
the signature and 0 for the id, but I use 0 for the signature combined with
unique id values. If you import a 'DLOG', this is what IB does: Each control
in the window gets ControlID { 0, n }, where n was the item's dialog item
number. These work just fine with HIViewFindByID() and ControlID() as long
as the { signature, id } pair is unique.

Multiple signatures would be needed if you were embedding controls from one
window into another and there was a reason you couldn't use different id
ranges, but otherwise I've yet to find a reason to burden myself with
multiple signatures. Not that the signature field is pointless, of course.
Apple uses its own signatures for HIViews owned by the system, but since
they're nonzero, my { 0, n } ControlIDs are still unique within my window.

For example, I have a window with over 50 items in it and it's a whole lot
easier to think of, assign, and use fifty unique numbers (1 - 50 work well
;-) in an enum definition, than it is to think of, enter, and use fifty
unique FourCharCodes. So I never touch the signature part of the ControlID
in IB, and I have enum declarations like this:

enum {
kID_OKButton = 1,
kID_CancelButton = 2,
kID_Prompt = 3,
kID_ActionPopup = 4
};

In a typical window I just use consecutive numbers, but that's not required,
of course. My preferences window has a tab control in it and the individual
tab contents are in separate windows. In that case I reserve a unique range
of 100 numbers such as 200-299 for each tab so I can add new items to a tab
later without having to worry about using an id which is already in use in
another tab.

My base window class has lots of member functions which work with controls
simply by taking the id:

SInt32 value = GetControlValue( kID_ActionPopup );

GetControlValue() calls GetControlByID() with the ControlID { 0,
kID_ActionPopup } and then uses GetControl32BitValue to get the control's
value if the resulting control is not NULL.

Larry
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: Set max chars for Unicode Edit Text control? (From: Scott Thompson <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.