This cry for help caught my attention since I've been adding localDispatch 
methods to insets.

        // IMO this is a gross hack! Insets should be changed so that
        // they call the actions they have to do with the insetButtonRel.
        // function and not in the edit(). This should be changed
        // (Jug 20020329)
#ifdef WITH_WARNINGS
#warning Please remove donot call inset->edit() here (Jug 20020812)
#endif

The attached patch works beautifully. Ok to apply?

-- 
Angus
Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.1078
diff -u -p -r1.1078 ChangeLog
--- src/ChangeLog	7 Mar 2003 18:44:52 -0000	1.1078
+++ src/ChangeLog	7 Mar 2003 22:10:12 -0000
@@ -1,5 +1,11 @@
 2003-03-07  Angus Leeming  <[EMAIL PROTECTED]>
 
+	* text3.C (dispatch): remove the 'gross hack' of calling inset->edit
+	when the LFUN_MOUSE_RELEASE should have been handled by
+	inset->localDispatch.
+
+2003-03-07  Angus Leeming  <[EMAIL PROTECTED]>
+
 	* BufferView_pimpl.C (dispatch):
 	* LyXAction.C (init):
 	* ToolbarDefaults.C (init):
Index: src/text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.41
diff -u -p -r1.41 text3.C
--- src/text3.C	7 Mar 2003 15:22:53 -0000	1.41
+++ src/text3.C	7 Mar 2003 22:10:13 -0000
@@ -1528,24 +1528,8 @@ Inset::RESULT LyXText::dispatch(FuncRequ
 
 			bv->owner()->message(inset_hit->editMessage());
 
-			if (isHighlyEditableInset(inset_hit)) {
-				// Highly editable inset, like math
-				UpdatableInset * inset = (UpdatableInset *) inset_hit;
-				FuncRequest cmd1(bv, LFUN_MOUSE_RELEASE, x, y, cmd.button());
-				inset->localDispatch(cmd1);
-			} else {
-				FuncRequest cmd1(bv, LFUN_MOUSE_RELEASE, x, y, cmd.button());
-				inset_hit->localDispatch(cmd1);
-				// IMO this is a gross hack! Insets should be changed so that
-				// they call the actions they have to do with the insetButtonRel.
-				// function and not in the edit(). This should be changed
-				// (Jug 20020329)
-#ifdef WITH_WARNINGS
-#warning Please remove donot call inset->edit() here (Jug 20020812)
-#endif
-				inset_hit->edit(bv, x, y, cmd.button());
-			}
-			break;
+			FuncRequest cmd1(bv, LFUN_MOUSE_RELEASE, x, y, cmd.button());
+			inset_hit->localDispatch(cmd1);
 		}
 
 		break;
Index: src/insets/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.591
diff -u -p -r1.591 ChangeLog
--- src/insets/ChangeLog	7 Mar 2003 21:44:48 -0000	1.591
+++ src/insets/ChangeLog	7 Mar 2003 22:10:17 -0000
@@ -1,5 +1,10 @@
 2003-03-07  Angus Leeming  <[EMAIL PROTECTED]>
 
+	* inseterror.C (localDispatch): new method; calls edit() on
+	LFUN_MOUSE_RELEASE.
+
+2003-03-07  Angus Leeming  <[EMAIL PROTECTED]>
+
 	* insetbibitem.C (localDispatch):
 	* insetbibtex.C (localDispatch):
 	* insetlabel.C (localDispatch):
Index: src/insets/insetcommand.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcommand.C,v
retrieving revision 1.60
diff -u -p -r1.60 insetcommand.C
--- src/insets/insetcommand.C	7 Mar 2003 15:58:02 -0000	1.60
+++ src/insets/insetcommand.C	7 Mar 2003 22:10:17 -0000
@@ -88,6 +88,10 @@ dispatch_result InsetCommand::localDispa
 	}
 	break;
 
+	case LFUN_MOUSE_RELEASE:
+		edit(cmd.view(), cmd.x, cmd.y, cmd.button());
+		break;
+
 	default:
 		break;
 	}
Index: src/insets/insetcommand.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcommand.h,v
retrieving revision 1.56
diff -u -p -r1.56 insetcommand.h
--- src/insets/insetcommand.h	27 Feb 2003 13:26:06 -0000	1.56
+++ src/insets/insetcommand.h	7 Mar 2003 22:10:17 -0000
@@ -70,7 +70,7 @@ public:
 	InsetCommandParams const & params() const { return p_; }
 	///
 	void setParams(InsetCommandParams const &);
-	/// small wrapper for the time being
+	///
 	virtual dispatch_result localDispatch(FuncRequest const & cmd);
 
 private:
Index: src/insets/inseterror.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/inseterror.C,v
retrieving revision 1.47
diff -u -p -r1.47 inseterror.C
--- src/insets/inseterror.C	25 Feb 2003 14:51:37 -0000	1.47
+++ src/insets/inseterror.C	7 Mar 2003 22:10:17 -0000
@@ -37,6 +37,21 @@ InsetError::~InsetError()
 }
 
 
+dispatch_result InsetError::localDispatch(FuncRequest const & cmd)
+{
+	dispatch_result result = UNDISPATCHED;
+
+	switch (cmd.action) {
+	case LFUN_MOUSE_RELEASE:
+		edit(cmd.view(), cmd.x, cmd.y, cmd.button());
+		break;
+
+	default:
+		break;
+	}
+
+	return result;
+}
 int InsetError::ascent(BufferView *, LyXFont const & font) const
 {
 	LyXFont efont;
Index: src/insets/inseterror.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/inseterror.h,v
retrieving revision 1.49
diff -u -p -r1.49 inseterror.h
--- src/insets/inseterror.h	25 Feb 2003 14:51:37 -0000	1.49
+++ src/insets/inseterror.h	7 Mar 2003 22:10:17 -0000
@@ -29,6 +29,8 @@ public:
 	///
 	~InsetError();
 	///
+	virtual dispatch_result localDispatch(FuncRequest const & cmd);
+	///
 	int ascent(BufferView *, LyXFont const &) const;
 	///
 	int descent(BufferView *, LyXFont const &) const;
Index: src/insets/insetexternal.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetexternal.C,v
retrieving revision 1.58
diff -u -p -r1.58 insetexternal.C
--- src/insets/insetexternal.C	7 Mar 2003 16:20:17 -0000	1.58
+++ src/insets/insetexternal.C	7 Mar 2003 22:10:18 -0000
@@ -85,6 +85,10 @@ dispatch_result InsetExternal::localDisp
 	}
 	break;
 
+	case LFUN_MOUSE_RELEASE:
+		edit(cmd.view(), cmd.x, cmd.y, cmd.button());
+		break;
+
 	default:
 		break;
 	}
Index: src/insets/insetgraphics.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphics.C,v
retrieving revision 1.155
diff -u -p -r1.155 insetgraphics.C
--- src/insets/insetgraphics.C	7 Mar 2003 18:44:57 -0000	1.155
+++ src/insets/insetgraphics.C	7 Mar 2003 22:10:19 -0000
@@ -241,6 +241,10 @@ dispatch_result InsetGraphics::localDisp
 	}
 	break;
 
+	case LFUN_MOUSE_RELEASE:
+		edit(cmd.view(), cmd.x, cmd.y, cmd.button());
+		break;
+
 	default:
 		result = DISPATCHED;
 		break;
Index: src/insets/insetinclude.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetinclude.C,v
retrieving revision 1.101
diff -u -p -r1.101 insetinclude.C
--- src/insets/insetinclude.C	7 Mar 2003 15:58:02 -0000	1.101
+++ src/insets/insetinclude.C	7 Mar 2003 22:10:20 -0000
@@ -138,6 +138,10 @@ dispatch_result InsetInclude::localDispa
 	}
 	break;
 
+	case LFUN_MOUSE_RELEASE:
+		edit(cmd.view(), cmd.x, cmd.y, cmd.button());
+		break;
+
 	default:
 		break;
 	}
Index: src/insets/insetlabel.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetlabel.C,v
retrieving revision 1.53
diff -u -p -r1.53 insetlabel.C
--- src/insets/insetlabel.C	7 Mar 2003 21:44:48 -0000	1.53
+++ src/insets/insetlabel.C	7 Mar 2003 22:10:20 -0000
@@ -74,6 +74,7 @@ dispatch_result InsetLabel::localDispatc
 		result = DISPATCHED;
 	}
 	break;
+
 	default:
 		result = InsetCommand::localDispatch(cmd);
 	}

Reply via email to