Mailing Lists: Apple Mailing Lists

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

kEventControlHit and Check box



Hi,

I'm converting an old application to Carbon and I have a problem with Check box controls: In my Carbon event handler for kEventControlHit, I get the check box value, but the value I get is the value before the click, not after. I have the same code for Sliders, scrollbars, bevel buttons (with toggle behaviour) and Tabs controls and it works fine for all of these, just not for check boxes. Does anyone have any idea what I'm doing wrong? Here's the (simplified to protect the innocent) code:

void CheckBox::InstallEventHandler()
{
OSStatus status;
static const EventTypeSpec events[] = {
{ kEventClassControl, kEventControlHit },
};

static EventHandlerUPP event_handler_UPP = NULL;
if ( event_handler_UPP == NULL )
event_handler_UPP = NewEventHandlerUPP( EventHandler );
status = ::InstallControlEventHandler( GetControl(), event_handler_UPP,
GetEventTypeCount(events), events, this, NULL );
}

pascal OSStatus CheckBox::EventHandler(EventHandlerCallRef handlerRef, EventRef event, void* userData)
{
CheckBox *button = (CheckBox *)userData;
int value = ::GetControlValue( button->GetControl() ); // This returns the wrong value
::CallNextEventHandler(handlerRef, event); // adding this in makes no difference
value = ::GetControlValue( button->GetControl() );
return eventNotHandledErr;
}

Jerry
_______________________________________________
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.



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.