On Friday 27 September 2002 7:36 am, R. Lahaye wrote: > Allan Rae wrote: > > On Fri, 27 Sep 2002, Rob Lahaye wrote: > > [...] > > > >>Why does this function only work on check and button > >> widgets? When I do, for example: > >> > >> bc().addReadOnly(dialog_->choice_width_unit) > >> > >>the choice widget is not disabled for a readonly document! > >> > >>Does this function only apply to a limited set of Xforms > >> widgets? If so, why? > > > > We call fl_activate and fl_deactivate functions with the > > FL_OBJECT so if some widget isn't deactivated then it's an > > XForms bug (or limitation or feature). > > This cannot be the reason. > > fl_activate and fl_deactivate work fine on any widgets in > Xforms. In fact, they are wrapped up in the LyX function > > setEnabled(FL_OBJECT *obj, bool enable) > > that has no problems at all. > > The addReadOnly must be the culprit, but I can't see why and > how. I can trace it no further than into > frontends/controllers/ButtonController.h > > 27: template <class Button, class Widget> > 28: class GuiBC : public ButtonControllerBase > 29: { > [...] > 43: void addReadOnly(Widget * obj) { > read_only_.push_back(obj); } [...] > > and then I'm lost. > > Why does this work only for push-buttons and check-buttons, > but not for other Xforms widgets (choice-lists, input fields > etc.) ? > > If this is a feature/bug, it's a LyX implemented feature/bug! > > Regards, > Rob.
Well, Rob, I haven't much time to delve, but the code doesn't look like it singles out certain widgets only. Below should get you started. Try adding a few judicious lyxerr statements. Angus controllers/ButtonControllerBase.C: ========================= bool ButtonControllerBase::readOnly(bool ro) { lyxerr[Debug::GUI] << "Setting controller ro: " << ro << std::endl; if (ro) { bp().input(ButtonPolicy::SMI_READ_ONLY); } else { bp().input(ButtonPolicy::SMI_READ_WRITE); } // Set the activation of widgets in the list of // readonly-able widgets refreshReadOnly(); // Set the activation of the Ok,Apply,Restore buttons refresh(); return ro; } controllers/ButtonController.tmpl: ======================= template <class Button, class Widget> void GuiBC<Button, Widget>::refreshReadOnly() { if (read_only_.empty()) return; bool const enable = !bp().isReadOnly(); typename Widgets::const_iterator end = read_only_.end(); typename Widgets::const_iterator iter = read_only_.begin(); for (; iter != end; ++iter) { setWidgetEnabled(*iter, enable); } } xforms/xformsBC.C: ============== void xformsBC::setWidgetEnabled(FL_OBJECT * obj, bool enabled) { setEnabled(obj, enabled); }