Fix again ticket #1720. This got broken during frontend reorganization.

The situation now is almost good, although preference and about LyX are now disabled.

I moved the code that sets buffer to 0 to LyXFunc::getStatus, where it belongs.
I also set lyx_view_ to 0 when the window does not have focus.



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30557 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2009-07-14 11:36:08 +00:00
parent 4dde959e6c
commit b05a94c3dd
3 changed files with 20 additions and 14 deletions

View File

@ -398,7 +398,22 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
//lyxerr << "LyXFunc::getStatus: cmd: " << cmd << endl;
FuncStatus flag;
Buffer * buf = lyx_view_ ? lyx_view_->buffer() : 0;
/* In LyX/Mac, when a dialog is open, the menus of the
application can still be accessed without giving focus to
the main window. In this case, we want to disable the menu
entries that are buffer or view-related.
If this code is moved somewhere else (like in
GuiView::getStatus), then several functions will not be
handled correctly.
*/
frontend::LyXView * lv = 0;
Buffer * buf = 0;
if (lyx_view_
&& (cmd.origin != FuncRequest::MENU || lyx_view_->hasFocus())) {
lv = lyx_view_;
buf = lyx_view_->buffer();
}
if (cmd.action == LFUN_NOACTION) {
flag.message(from_utf8(N_("Nothing to do")));
@ -663,11 +678,11 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
break;
// Does the view know something?
if (!lyx_view_) {
if (!lv) {
enable = false;
break;
}
if (lyx_view_->getStatus(cmd, flag))
if (lv->getStatus(cmd, flag))
break;
// If we do not have a BufferView, then other functions are disabled

View File

@ -66,6 +66,8 @@ public:
virtual void setBuffer(Buffer * b) = 0; ///< \c Buffer to set.
///
virtual bool closeBuffer() = 0;
///
virtual bool hasFocus() const = 0;
/// load a document into the current workarea.
virtual Buffer * loadDocument(

View File

@ -1223,17 +1223,6 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
bool enable = true;
Buffer * buf = buffer();
/* In LyX/Mac, when a dialog is open, the menus of the
application can still be accessed without giving focus to
the main window. In this case, we want to disable the menu
entries that are buffer-related.
Note that this code is not perfect, as bug 1941 attests:
http://bugzilla.lyx.org/show_bug.cgi?id=1941#c4
*/
if (cmd.origin == FuncRequest::MENU && !hasFocus())
buf = 0;
if (cmd.origin == FuncRequest::TOC) {
GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
FuncStatus fs;