I have a list in a data browser control that is set to only allow
one thing to be selected at a time. It has a
DataBrowserItemNotificationUPP attached to it so I can keep track
of the kDataBrowserItemSelected and kDataBrowserItemDeselected events.
My plan was to have it so that if an item is selected from the
list, some other controls would be activated and their data
populated by whatever was selected. Similarly when there is no
selection, the controls would be disabled.
The problem is that the events are happening in the opposite order
of what I expected. When the first item is selected in the list, I
get the kDataBrowserItemSelected correctly. When a second item in
the list is selected, I get another kDataBrowserItemSelected (which
causes the process to enable the other controls and populate them)
followed by a kDataBrowserItemDeselected (which causes the other
controls to be disabled.) So after the first item is selected,
nothing else is getting enabled.
I am obviously doing something incorrectly, but I’m not sure what.
I haven’t found any good documentation on using the callbacks, or
why it is allowing a brief moment where two things are selected. Is
there a way to get the information in the deselect/select order?
You can't really assume a particular order of messages. Apparently
the current data browser implementation selects the second item
before deselecting the first item. That might change in the future.
Who knows? It -is- doing the correct thing in that, after a series of
messages, a single item is once again selected.
Should I instead be trying to use kDataBrowserSelectionSetChanged
in some way? Right now I’m thinking of writing a complicated
algorithm to try and manually switch things into the opposite
order, but I would prefer not to go down that route.
Why complicate things needlessly? What I tend to do is to keep a
selection count variable that tracks the number of selected items at
any particular time and update the state of things as needed. This
works well for the case where you want a single item selected as well
as multiple items. All of the enables/disables, etc., won't be seen
until the next time through the event loop, so it doesn't really
matter that you end up doing a superfluous disable in your case.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden