diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2007-05-10 12:06:31 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2007-05-10 12:06:31 +0000 |
| commit | e42fac099f8d56e24987183edaf0e3d2386770b8 (patch) | |
| tree | 88c3c3d2f19a752fc8fa22ada59ed05c350cfa8c /fluid/Fl_Menu_Type.cxx | |
| parent | ee1d3823a0e6c1d62554311341dc01cc002b5a1a (diff) | |
Annoyed by the limitation in Fluid to generate keyboard shortucts for either Mac or Win32/Linux, I added a Project option. If checked, all keyboard shortcuts containing the modifier FL_CTRL or FL_META will instead be writte as FL_COMMAND|shortcut. This will generate FL_META shortcuts on the Mac and FL_CTRL shortcuts on the PC.
This is compatible to old Fluid files. The .fl file will not change (except for the project wide setting itself) and no information is lost. As the only limitation, it is not possible to write any combination of FL_META and FL_CTRL while "use FL_COMMAND" is set.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5808 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'fluid/Fl_Menu_Type.cxx')
| -rw-r--r-- | fluid/Fl_Menu_Type.cxx | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/fluid/Fl_Menu_Type.cxx b/fluid/Fl_Menu_Type.cxx index fe2bc73a9..94bd160e7 100644 --- a/fluid/Fl_Menu_Type.cxx +++ b/fluid/Fl_Menu_Type.cxx @@ -308,9 +308,14 @@ void Fl_Menu_Item_Type::write_item() { } } else write_c("\"\""); - if (((Fl_Button*)o)->shortcut()) - write_c(", 0x%x, ", ((Fl_Button*)o)->shortcut()); - else + if (((Fl_Button*)o)->shortcut()) { + int s = ((Fl_Button*)o)->shortcut(); + if (use_FL_COMMAND && (s & (FL_CTRL|FL_META))) { + write_c(", FL_COMMAND|0x%x, ", s & ~(FL_CTRL|FL_META)); + } else { + write_c(", 0x%x, ", s); + } + } else write_c(", 0, "); if (callback()) { const char* k = is_name(callback()) ? 0 : class_name(1); @@ -544,7 +549,13 @@ void Shortcut_Button::draw() { if (value()) draw_box(FL_DOWN_BOX, (Fl_Color)9); else draw_box(FL_UP_BOX, FL_WHITE); fl_font(FL_HELVETICA,14); fl_color(FL_FOREGROUND_COLOR); - fl_draw(fl_shortcut_label(svalue),x()+6,y(),w(),h(),FL_ALIGN_LEFT); + if (use_FL_COMMAND && (svalue & (FL_CTRL|FL_META))) { + char buf[1024]; + fl_snprintf(buf, 1023, "Command+%s", fl_shortcut_label(svalue&~(FL_CTRL|FL_META))); + fl_draw(buf,x()+6,y(),w(),h(),FL_ALIGN_LEFT); + } else { + fl_draw(fl_shortcut_label(svalue),x()+6,y(),w(),h(),FL_ALIGN_LEFT); + } } int Shortcut_Button::handle(int e) { @@ -562,7 +573,7 @@ int Shortcut_Button::handle(int e) { v = Fl::event_state()&(FL_META|FL_ALT|FL_CTRL|FL_SHIFT) | Fl::event_key(); if (v == FL_BackSpace && svalue) v = 0; } - if (v != svalue) {svalue = v; set_changed(); redraw(); do_callback(); } + if (v != svalue) {svalue = v; set_changed(); redraw(); do_callback(); } return 1; } else if (e == FL_UNFOCUS) { int c = changed(); value(0); if (c) set_changed(); |
