Opened 17 years ago

Closed 17 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:
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 by axeld, 17 years ago

Status: newassigned

comment:2 by axeld, 17 years ago

Resolution: fixed
Status: assignedclosed

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

comment:3 by hiron, 17 years ago

Resolution: fixed
Status: closedreopened

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

In BMenuItem::SetTrigger(char)

fTriggerIndex = pos - Label();

comment:4 by axeld, 17 years ago

Resolution: fixed
Status: reopenedclosed

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

Note: See TracTickets for help on using tickets.