diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2008-04-23 14:19:58 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2008-04-23 14:19:58 +0000 |
| commit | 8683ea2c810a3d689e436a8d13abbbba50efc4f5 (patch) | |
| tree | 07f4dd10cee8d33ca9b94b900ff15c056662526e /fluid/Fl_Widget_Type.cxx | |
| parent | 8d6b757bfe1579c1c09d627329bbf15875d52cc5 (diff) | |
Adding keyboard shortcut to Fl_Value_Input and Fl_Text_Editor
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6111 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'fluid/Fl_Widget_Type.cxx')
| -rw-r--r-- | fluid/Fl_Widget_Type.cxx | 62 |
1 files changed, 40 insertions, 22 deletions
diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx index c67bb6438..e1213008a 100644 --- a/fluid/Fl_Widget_Type.cxx +++ b/fluid/Fl_Widget_Type.cxx @@ -2162,30 +2162,26 @@ void Fl_Widget_Type::write_widget_code() { write_c("%s%s->type(%d);\n", indent(), var, o->type()); if (o->box() != tplate->box() || subclass()) write_c("%s%s->box(FL_%s);\n", indent(), var, boxname(o->box())); - if (is_input()) { - Fl_Input_* b = (Fl_Input_*)o; - if (b->shortcut()) { - int s = b->shortcut(); - if (use_FL_COMMAND && (s & (FL_CTRL|FL_META))) { - write_c("%s%s->shortcut(FL_COMMAND|0x%x);\n", indent(), var, s & ~(FL_CTRL|FL_META)); - } else { - write_c("%s%s->shortcut(0x%x);\n", indent(), var, s); - } - } + + // write shortcut command if needed + int shortcut = 0; + if (is_button()) shortcut = ((Fl_Button*)o)->shortcut(); + else if (is_input()) shortcut = ((Fl_Input_*)o)->shortcut(); + else if (is_value_input()) shortcut = ((Fl_Value_Input*)o)->shortcut(); + else if (is_text_display()) shortcut = ((Fl_Text_Display*)o)->shortcut(); + if (shortcut) { + if (use_FL_COMMAND && (shortcut & (FL_CTRL|FL_META))) { + write_c("%s%s->shortcut(FL_COMMAND|0x%x);\n", indent(), var, shortcut & ~(FL_CTRL|FL_META)); + } else { + write_c("%s%s->shortcut(0x%x);\n", indent(), var, shortcut); + } } + if (is_button()) { Fl_Button* b = (Fl_Button*)o; if (b->down_box()) write_c("%s%s->down_box(FL_%s);\n", indent(), var, boxname(b->down_box())); if (b->value()) write_c("%s%s->value(1);\n", indent(), var); - if (b->shortcut()) { - int s = b->shortcut(); - if (use_FL_COMMAND && (s & (FL_CTRL|FL_META))) { - write_c("%s%s->shortcut(FL_COMMAND|0x%x);\n", indent(), var, s & ~(FL_CTRL|FL_META)); - } else { - write_c("%s%s->shortcut(0x%x);\n", indent(), var, s); - } - } } else if (!strcmp(type_name(), "Fl_Input_Choice")) { Fl_Input_Choice* b = (Fl_Input_Choice*)o; if (b->down_box()) write_c("%s%s->down_box(FL_%s);\n", indent(), var, @@ -2348,6 +2344,14 @@ void Fl_Widget_Type::write_properties() { Fl_Input_* b = (Fl_Input_*)o; if (b->shortcut()) write_string("shortcut 0x%x", b->shortcut()); } + if (is_value_input()) { + Fl_Value_Input* b = (Fl_Value_Input*)o; + if (b->shortcut()) write_string("shortcut 0x%x", b->shortcut()); + } + if (is_text_display()) { + Fl_Text_Display* b = (Fl_Text_Display*)o; + if (b->shortcut()) write_string("shortcut 0x%x", b->shortcut()); + } if (is_button()) { Fl_Button* b = (Fl_Button*)o; if (b->down_box()) { @@ -2537,10 +2541,12 @@ void Fl_Widget_Type::read_property(const char *c) { hotspot(1); } else if (!strcmp(c,"class")) { subclass(read_word()); - } else if (is_button() && !strcmp(c,"shortcut")) { - ((Fl_Button*)o)->shortcut(strtol(read_word(),0,0)); - } else if (is_input() && !strcmp(c,"shortcut")) { - ((Fl_Input_*)o)->shortcut(strtol(read_word(),0,0)); + } else if (!strcmp(c,"shortcut")) { + int shortcut = strtol(read_word(),0,0); + if (is_button()) ((Fl_Button*)o)->shortcut(shortcut); + else if (is_input()) ((Fl_Input_*)o)->shortcut(shortcut); + else if (is_value_input()) ((Fl_Value_Input*)o)->shortcut(shortcut); + else if (is_text_display()) ((Fl_Text_Display*)o)->shortcut(shortcut); } else { if (!strncmp(c,"code",4)) { int n = atoi(c+4); @@ -2717,6 +2723,18 @@ void Fl_Widget_Type::copy_properties() { d->shortcut(s->shortcut()); } + // copy all attributes specific to widgets derived from Fl_Value_Input + if (is_value_input()) { + Fl_Value_Input* d = (Fl_Value_Input*)live_widget, *s = (Fl_Value_Input*)o; + d->shortcut(s->shortcut()); + } + + // copy all attributes specific to widgets derived from Fl_Text_Display + if (is_text_display()) { + Fl_Text_Display* d = (Fl_Text_Display*)live_widget, *s = (Fl_Text_Display*)o; + d->shortcut(s->shortcut()); + } + // copy all attributes specific to Fl_Valuator and derived classes if (is_valuator()) { Fl_Valuator* d = (Fl_Valuator*)live_widget, *s = (Fl_Valuator*)o; |
