BMenuItem::SetTrigger() and SetAutomaticTrigger() now also update fTriggerIndex.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17006 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-04-04 13:13:18 +00:00
parent 0f11085c6c
commit cb2998af29
2 changed files with 16 additions and 11 deletions
+1 -6
View File
@@ -1804,13 +1804,8 @@ BMenu::CalcTriggers()
BMenuItem *item = ItemAt(i);
if (item->Trigger() == 0) {
const char *newTrigger = ChooseTrigger(item->Label(), &triggersList);
if (newTrigger != NULL) {
if (newTrigger != NULL)
item->SetAutomaticTrigger(*newTrigger);
// TODO: This is crap. I'd prefer to have
// BMenuItem::SetSysTrigger(const char *) update fTriggerIndex.
// This isn't the case on beos, but it will probably be like that on haiku.
item->fTriggerIndex = newTrigger - item->Label();
}
}
}
}
+15 -5
View File
@@ -276,10 +276,14 @@ BMenuItem::SetTrigger(char trigger)
{
fUserTrigger = trigger;
if (strchr(fLabel, trigger) != 0)
const char* pos = strchr(Label(), trigger);
if (pos != NULL) {
fAutomaticTrigger = trigger;
else
fAutomaticTrigger = -1;
fTriggerIndex = pos - Label();
} else {
fAutomaticTrigger = 0;
fTriggerIndex = -1;
}
if (fSuper != NULL)
fSuper->InvalidateLayout();
@@ -821,7 +825,13 @@ BMenuItem::_DrawControlChar(char shortcut, BPoint where)
void
BMenuItem::SetAutomaticTrigger(char ch)
BMenuItem::SetAutomaticTrigger(char trigger)
{
fAutomaticTrigger = ch;
fAutomaticTrigger = trigger;
const char* pos = strchr(Label(), trigger);
if (pos != NULL)
fTriggerIndex = pos - Label();
else
fTriggerIndex = -1;
}