From c1fe316855ecb6a6c0159fc969c8ddef2c5d9b3c Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Sat, 12 Mar 2016 17:44:24 +0000 Subject: Add localization of modifier key names in shortcut labels. Modifier key names like Alt, Shift, Ctrl, Meta can now be localized by setting global string pointers. See documentation of fl_shortcut_label(). Port branch-1.3, svn r 11321. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11354 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Menu.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/Fl_Menu.cxx') diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx index 1e3fa5f84..97a2574b2 100644 --- a/src/Fl_Menu.cxx +++ b/src/Fl_Menu.cxx @@ -482,10 +482,12 @@ void menuwindow::drawentry(const Fl_Menu_Item* m, int n, int eraseit) { button ? button->textsize() : FL_NORMAL_SIZE); const char *k, *s = fl_shortcut_label(m->shortcut_, &k); if (fl_utf_nb_char((const unsigned char*)k, (int) strlen(k))<=4) { - // righ-align the modifiers and left-align the key - char buf[32]; strcpy(buf, s); buf[k-s] = 0; + // right-align the modifiers and left-align the key + char *buf = (char*)malloc(k-s+1); + memcpy(buf, s, k-s); buf[k-s] = 0; fl_draw(buf, xx, yy, ww-shortcutWidth, hh, FL_ALIGN_RIGHT); fl_draw( k, xx+ww-shortcutWidth, yy, shortcutWidth, hh, FL_ALIGN_LEFT); + free(buf); } else { // right-align to the menu fl_draw(s, xx, yy, ww-4, hh, FL_ALIGN_RIGHT); -- cgit v1.2.3