Opened 10 years ago

Closed 10 years ago

#1506 closed bug (fixed)

BMenuItem's trigger is drawn at incorrect position.

Reported by: hiron Owned by: axeld
Priority: normal Milestone: R1
Component: Kits/Interface Kit Version: R1/pre-alpha1
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

On Haiku, BMenuItem's searching trigger character in its label is case-sensitive. On BeOS R5, it is case-insensitive. To reproduce:

BMenuItem* item = new BMenuItem("Quit", NULL);
item->SetTrigger('q');

This menu item draws no trigger underline on Haiku against that the first character (Q) is underlined on BeOS R5.

And if there are multi-byte characters, it fails to locate a correct position. To reproduce:

// "\xe3\x81\x82" is a Japanese hiragana letter A (U+3042) (single character)
BMenuItem* item = new BMenuItem("\xe3\x81\x82haiku", NULL);
item->SetTrigger('h');

The trigger underline is drawn under 'i', of course the expected behavior is it draws under 'h'. (Even though BeOS R5 has a same bug...)

It seems that in BMenuItem::DrawContent,

font.GetEscapements(fLabel, fTriggerIndex + 1, escapements);

fTriggerIndex has an index in bytes but BFont::GetEscapements takes a number of characters, not bytes.

Change History (4)

comment:1 Changed 10 years ago by axeld

  • Status changed from new to assigned

comment:2 Changed 10 years ago by axeld

  • Resolution set to fixed
  • Status changed from assigned to closed

Thanks for the report. It's fixed in hrev22384.

comment:3 Changed 10 years ago by hiron

  • Resolution fixed deleted
  • Status changed from closed to reopened

The latter one is not fixed yet. fTriggerIndex still holds a byte position.

In BMenuItem::SetTrigger(char)

fTriggerIndex = pos - Label();

comment:4 Changed 10 years ago by axeld

  • Resolution set to fixed
  • Status changed from reopened to closed

Thanks a lot for retesting! It's fixed now in hrev22476.

Note: See TracTickets for help on using tickets.