Thomas Haupt
|
Re: Identifying Widget in a Callback
|
Thomas Haupt
03/08/2010 6:11 AM
post48984
|
Re: Identifying Widget in a Callback
Hi,
there are at least three different ways to recognize the widget which invoked a callback. One of them, attaching unique
user data to each widget, you already named - and that is often the best way.
Of course you could also compare the 'widget' pointer directly, as in:
if ( widget == ABW_widget1 ) {
/* do widget1 processing */
}
else if ( widget == ABW_widget2 ) {
/* do widget2 processing */
}
else {
/* do something else? */
}
But then it's much nicer to go by the 'widget name' (which is actually an index):
switch ( ApName( widget ) ) {
case ABN_widget1:
/* do widget1 processing */
case ABN_widget2:
/* do widget2 processing */
default:
/* do something else? */
}
- Thomas
|
|
|