Opened 13 months ago
Last modified 13 months ago
#18648 new bug
BOptionPopUp sets value even if not available — at Version 1
Reported by: | jackburton | Owned by: | nobody |
---|---|---|---|
Priority: | normal | Milestone: | Unscheduled |
Component: | Kits/Interface Kit | Version: | R1/beta4 |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description (last modified by )
With BOptionPopUp::SetValue() you can set a value which does not exist. As you can see from the implementation, it sets the value of the BControl by calling BControl::SetValue(), but later it could return without setting the correct option, since there might be no option with that value.
Calling Value() will then return the newly set value.
void BOptionPopUp::SetValue(int32 value) { BControl::SetValue(value); BMenu* menu = fMenuField->Menu(); if (menu == NULL) return; int32 numItems = menu->CountItems(); for (int32 i = 0; i < numItems; i++) { BMenuItem* item = menu->ItemAt(i); if (item && item->Message()) { int32 itemValue; item->Message()->FindInt32("be:value", &itemValue); if (itemValue == value) { item->SetMarked(true); break; } } } }
If I remember correctly, this behaviour is inherited from BeOS, but maybe it doesn't make much sense, and could be confusing.
Note:
See TracTickets
for help on using tickets.