]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_cursor.C
Jean-Marc's fix for wrong descent
[lyx.git] / src / mathed / math_cursor.C
index 5e89cc4b87dcac47d4ef45afeda15ffc1a9f23eb..cfc4f88e5688c1bb4a4b66f979b0ed0142a244ab 100644 (file)
@@ -420,12 +420,13 @@ bool MathCursor::backspace()
        }
 
        if (pos() == 0) {
-               if (par()->ncols() == 1 && par()->nrows() == 1 && depth() == 1 && size() == 0)
+               if (par()->ncols() == 1 &&
+                         par()->nrows() == 1 &&
+                         depth() == 1 &&
+                         size() == 0)
                        return false;
-               else{
-                       pullArg();
-                       return true;
-               }
+               pullArg();
+               return true;
        }
 
        if (inMacroMode()) {
@@ -438,7 +439,7 @@ bool MathCursor::backspace()
 
        --pos();
        plainErase();
-        return true;
+       return true;
 }
 
 
@@ -1409,21 +1410,46 @@ MathCursorPos MathCursor::normalAnchor() const
 }
 
 
-MathInset::result_type MathCursor::dispatch(FuncRequest const & cmd)
-{
+dispatch_result MathCursor::dispatch(FuncRequest const & cmd)
+{
+       // mouse clicks are somewhat special 
+       // check
+       switch (cmd.action) {
+               case LFUN_MOUSE_PRESS:
+               case LFUN_MOUSE_MOTION:
+               case LFUN_MOUSE_RELEASE:
+               case LFUN_MOUSE_DOUBLE: {
+                       MathCursorPos & pos = Cursor_.back();
+                       dispatch_result res = UNDISPATCHED;
+                       int x = 0, y = 0;
+                       getPos(x, y);
+                       if (x < cmd.x && hasPrevAtom()) {
+                               res = prevAtom().nucleus()->dispatch(cmd, pos.idx_, pos.pos_);
+                               if (res != UNDISPATCHED)
+                                       return res;
+                       }
+                       if (x > cmd.x && hasNextAtom()) {
+                               res = nextAtom().nucleus()->dispatch(cmd, pos.idx_, pos.pos_);
+                               if (res != UNDISPATCHED)
+                                       return res;
+                       }
+               }
+               default:
+                       break;
+       }
+
        for (int i = Cursor_.size() - 1; i >= 0; --i) {
                MathCursorPos & pos = Cursor_[i];
-               MathInset::result_type
-                       res = pos.par_->dispatch(cmd, pos.idx_, pos.pos_);
-               if (res != MathInset::UNDISPATCHED) {
-                       if (res == MathInset::DISPATCHED_POP) {
+               dispatch_result res = pos.par_->dispatch(cmd, pos.idx_, pos.pos_);
+               if (res != UNDISPATCHED) {
+                       if (res == DISPATCHED_POP) {
                                Cursor_.shrink(i + 1);
                                selClear();
                        }
                        return res;
                }
        }
-       return MathInset::UNDISPATCHED;
+       return UNDISPATCHED;
 }