summaryrefslogtreecommitdiff
path: root/src/Fl_Menu.cxx
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2016-03-12 17:44:24 +0000
committerAlbrecht Schlosser <albrechts.fltk@online.de>2016-03-12 17:44:24 +0000
commitc1fe316855ecb6a6c0159fc969c8ddef2c5d9b3c (patch)
tree2fa9c28112269fc440cd9fb1ed34acbf9044a705 /src/Fl_Menu.cxx
parent3b1434238879cd4cdb0cf1d91563c5e661698f78 (diff)
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
Diffstat (limited to 'src/Fl_Menu.cxx')
-rw-r--r--src/Fl_Menu.cxx6
1 files changed, 4 insertions, 2 deletions
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);