diff --git a/include/mask.cpp b/include/mask.cpp index 9e9eebdf7..50c67df6f 100755 --- a/include/mask.cpp +++ b/include/mask.cpp @@ -24,7 +24,9 @@ bool TMask::test_focus_change(WINDOW next) { bool ok = TRUE; - TMask_field& prev = fld(_focus); + TMask_field& prev = fld(_focus); + _next_fld = next == NULL_WIN ? DLG_NULL : fld(find_field_win(next)).dlg(); + if (prev.win() != next) { ok = prev.test_focus_change(); @@ -440,7 +442,9 @@ void TMask::start_run() load_checks(); - const int max = fields(); + const int max = fields(); + + _next_fld = DLG_NULL; for (int i = 0; i < max; i++) { TMask_field& f = fld(i); @@ -673,8 +677,6 @@ void TMask::set_focus() // Move the focus to the next (+1) or previous(-1) valid control void TMask::move_focus_field(int d) { - if (!test_focus_change()) - return; TMask_field& f = fld(_focus); if (f.class_id() == CLASS_RADIO_FIELD) @@ -687,6 +689,10 @@ void TMask::move_focus_field(int d) } const int focus = find_active_field(_focus+d, d); + + if (!test_focus_change(fld(focus).win())) + return; + if (fld(focus).parent() == f.parent() || check_current_page()) _focus = focus; @@ -694,7 +700,7 @@ void TMask::move_focus_field(int d) } bool TMask::stop_run(KEY key) -{ +{ if (key != K_AUTO_ENTER && key != K_FORCE_CLOSE) { const int last = fields(); @@ -732,7 +738,10 @@ bool TMask::stop_run(KEY key) if (!ok) return FALSE; } if (is_running()) // Gestisce correttamenete le maschere chiuse + { get_mask_fields(); + _next_fld = DLG_NULL; + } return TWindow::stop_run(key); } @@ -919,7 +928,7 @@ int TMask::find_first_field(WINDOW w, int dir) const bool TMask::check_current_page() { - if (!test_focus_change()) + if (!test_focus_change()) return FALSE; /* diff --git a/include/mask.h b/include/mask.h index a37c56263..56559dcda 100755 --- a/include/mask.h +++ b/include/mask.h @@ -40,7 +40,8 @@ class TMask : public TWindow TArray _field; // Fields in the mask int _first_focus; // First control to have focus - int _focus; // Control with focus + int _focus; // Control with focus + int _next_fld; // Control who is gaining the focus int _sheets; // Number of sheets MASK_HANDLER _handler; // User defined key handler @@ -129,7 +130,8 @@ public: virtual void close(); virtual void activate(bool on = TRUE); - int id2pos(short id) const; + int id2pos(short id) const; + short next_fld() const { return _next_fld;} // id of the field who is gaining the focus DLG_NULL is not exists TMask_field& fld(int i) const { return (TMask_field&)_field[i]; } // Ritorna il campo i-esimo della maschera TMask_field& field(short id) const; // field with given id TEdit_field& efield(short id) const; // edit-field with given id diff --git a/include/maskfld.cpp b/include/maskfld.cpp index d97a122b1..01cf04eef 100755 --- a/include/maskfld.cpp +++ b/include/maskfld.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include @@ -1637,7 +1637,7 @@ bool TBrowse::empty_check() TEdit_field::TEdit_field(TMask* mask) : TMask_field(mask), _browse(NULL), _sheet(NULL), - _buttonwin(NULL_WIN), _check(CHECK_NONE), _check_enabled(TRUE), + _buttonwin(NULL_WIN), _check(CHECK_NONE), _check_enabled(FALSE), _forced(FALSE) {} @@ -1770,6 +1770,7 @@ bool TEdit_field::parse_item(TScanner& scanner) _browse->set_insert(tabmaskname); } + _check_enabled = TRUE; return TRUE; } @@ -1783,8 +1784,11 @@ bool TEdit_field::parse_item(TScanner& scanner) if (what == "US" || what == "AL") _browse = new TBrowse(this, b->cursor()); - if (_browse) + if (_browse) + { + _check_enabled = TRUE; return _browse->parse_copy(what, *b); + } #ifdef DBG return yesnofatal_box("Impossibile COPY senza USE nel campo %d", dlg()); @@ -1805,7 +1809,8 @@ bool TEdit_field::parse_item(TScanner& scanner) #ifdef DBG if (_sheet) return yesnofatal_box("SHEET duplicato nel campo %d", dlg()); #endif - _sheet = new TList_sheet(this, _prompt, scanner.string()); + _sheet = new TList_sheet(this, _prompt, scanner.string()); + _check_enabled = TRUE; return TRUE; }