]> git.lyx.org Git - features.git/commitdiff
Finally fixed the problems with clicking on insets
authorJürgen Vigna <jug@sad.it>
Fri, 24 Mar 2000 13:24:58 +0000 (13:24 +0000)
committerJürgen Vigna <jug@sad.it>
Fri, 24 Mar 2000 13:24:58 +0000 (13:24 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@625 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
src/BufferView.C
src/insets/insetcollapsable.C
src/insets/insetert.C
src/insets/insetert.h
src/mathed/formula.C
src/text2.C

index feca0d7ab77fecf287e1b2d2bd2d8e688d6aa9d3..471e5c0a85cb96fd9cf05cc8eb2626c05241f97a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2000-03-24  Juergen Vigna  <jug@sad.it>
+
+       * src/insets/insetcollapsable.C (Edit): 
+       * src/mathed/formula.C (InsetButtonRelease): 
+       (InsetButtonPress): fixed for new handling of ButtonPress/Release
+       handling.
+
+       * src/BufferView.C (workAreaButtonPress): 
+       (workAreaButtonRelease): 
+       (checkInsetHit): Finally fixed the clicking on insets be handled
+       correctly!
+
+       * src/insets/insetert.C (Edit): inserted this call so that ERT
+       insets work always with LaTeX-font
+
 2000-03-21  Kayvan A. Sylvan  <kayvan@camel.internal.sylvan.com>
 
        * src/lyx_main.C (easyParse): Removed misplaced gui=false which
index 926f77959a0566ee8507a9f5ace7071a528d4a06..abf7d708359deb401f3be99419a8654bc0ee8062 100644 (file)
@@ -662,7 +662,7 @@ void BufferView::workAreaButtonPress(int xpos, int ypos, unsigned int button)
                
                /* Check whether the inset was hit. If not reset mode,
                   otherwise give the event to the inset */
-               if (inset_hit) {
+               if (inset_hit == the_locking_inset) {
                        the_locking_inset->
                                InsetButtonPress(this,
                                                 xpos, ypos,
@@ -673,7 +673,8 @@ void BufferView::workAreaButtonPress(int xpos, int ypos, unsigned int button)
                }
        }
        
-       selection_possible = true;
+       if (!inset_hit)
+               selection_possible = true;
        screen->HideCursor();
        
        // Right button mouse click on a table
@@ -730,12 +731,15 @@ void BufferView::workAreaButtonPress(int xpos, int ypos, unsigned int button)
        updateScrollbar();
        
        // Single left click in math inset?
-       if (inset_hit != 0 && inset_hit->Editable()==Inset::HIGHLY_EDITABLE) {
+       if ((inset_hit != 0) &&
+           (inset_hit->Editable()==Inset::HIGHLY_EDITABLE)) {
                // Highly editable inset, like math
+               UpdatableInset *inset = (UpdatableInset *)inset_hit;
                selection_possible = false;
                owner_->updateLayoutChoice();
-               owner_->getMiniBuffer()->Set(inset_hit->EditMessage());
-               inset_hit->Edit(this, xpos, ypos, button);
+               owner_->getMiniBuffer()->Set(inset->EditMessage());
+               inset->InsetButtonPress(this, xpos, ypos, button);
+               inset->Edit(this, xpos, ypos, button);
                return;
        } 
        
@@ -869,7 +873,13 @@ void BufferView::workAreaButtonRelease(int x, int y, unsigned int button)
                }
 
                owner_->getMiniBuffer()->Set(inset_hit->EditMessage());
-               inset_hit->Edit(this, x, y, button);
+               if (inset_hit->Editable()==Inset::HIGHLY_EDITABLE) {
+                       // Highly editable inset, like math
+                       UpdatableInset *inset = (UpdatableInset *)inset_hit;
+                       inset->InsetButtonRelease(this, x, y, button);
+               } else {
+                       inset_hit->Edit(this, x, y, button);
+               }
                return;
        }
 
@@ -964,7 +974,10 @@ Inset * BufferView::checkInsetHit(int & x, int & y)
   
        int y_tmp = y + screen->first;
   
+       LyXCursor & old_cursor = text->cursor;
+       text->SetCursorFromCoordinates(x,y);
        LyXCursor & cursor = text->cursor;
+
        bool is_rtl = text->real_current_font.isVisibleRightToLeft();
 
        if (cursor.pos < cursor.par->Last()
@@ -1018,9 +1031,9 @@ Inset * BufferView::checkInsetHit(int & x, int & y)
                        return tmpinset;
                } else {
                        text->CursorRight();
-                       return 0;
                }
        }
+       text->SetCursor(old_cursor.par, old_cursor.pos);
        return 0;
 }
 
index fe51decf1a72c32b82c30bce63739e63c5b7f4ec..735439b5637bd02247145744026efc8d169856bd 100644 (file)
@@ -136,11 +136,8 @@ void InsetCollapsable::Edit(BufferView *bv, int x, int y, unsigned int button)
        collapsed = false;
        UpdateLocal(bv, true);
        InsetText::Edit(bv, 0, 0, button);
-    } else if (button && (x < button_x)  &&
-       (y < (labelfont.maxDescent()+labelfont.maxAscent()))) {
-       collapsed = true;
-       UpdateLocal(bv, false);
-        bv->unlockInset(this);
+    } else if (button && (x < button_x)) {
+       return;
     } else {
        InsetText::Edit(bv, x-top_x, y, button);
     }
index 27ddcdd7d8b95552c7af2e417252b8553948cbc4..ad7cb29f461bd062b0cde651709cf76333747ff8 100644 (file)
@@ -62,3 +62,11 @@ void InsetERT::SetFont(BufferView *, LyXFont const &, bool)
               _("Not permitted to change font-types inside ERT-insets!"),
               _("Sorry."));
 }
+
+void InsetERT::Edit(BufferView * bv, int x, int y, unsigned int button)
+{
+    InsetCollapsable::Edit(bv, x, y, button);
+    LyXFont font(LyXFont::ALL_SANE);
+    font.setLatex (LyXFont::ON);
+    current_font = real_current_font = font;
+}
index cea113cb60e7181c110568628e3cee8fe809c103..b0600724085b848a69b94f161b9709fbe48428e1 100644 (file)
@@ -44,6 +44,8 @@ public:
     ///
     void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
     ///
+    void Edit(BufferView *, int, int, unsigned int);
+    ///
 };
 
 #endif
index 430fe075ecfa8761ebd609f847ac36e819598daf..564f78050b4596fd244f1b242bbad4467983c659 100644 (file)
@@ -628,15 +628,17 @@ void InsetFormula::UpdateLocal(BufferView * bv)
 void InsetFormula::InsetButtonRelease(BufferView * bv,
                                      int x, int y, int /*button*/)
 {
-    HideInsetCursor(bv);
-    x += par->xo;
-    y += par->yo;
-    mathcursor->SetPos(x, y);
-    ShowInsetCursor(bv);
-    if (sel_flag) {
-       sel_flag = false; 
-       sel_x = sel_y = 0;
-       bv->updateInset(this, false); 
+    if (mathcursor) {
+       HideInsetCursor(bv);
+       x += par->xo;
+       y += par->yo;
+       mathcursor->SetPos(x, y);
+       ShowInsetCursor(bv);
+       if (sel_flag) {
+           sel_flag = false; 
+           sel_x = sel_y = 0;
+           bv->updateInset(this, false); 
+       }
     }
 }
 
@@ -645,8 +647,8 @@ void InsetFormula::InsetButtonPress(BufferView * bv,
                                    int x, int y, int /*button*/)
 {
     sel_flag = false;
-    sel_x = x;  sel_y = y; 
-    if (mathcursor->Selection()) {
+    sel_x = x;  sel_y = y;
+    if (mathcursor && mathcursor->Selection()) {
        mathcursor->SelClear();
        bv->updateInset(this, false); 
     }
index a24bd80ee99eac758964de36ff386a19899c916f..f69ff60516d24b28dade7b89a71e1151ed9dd4ce 100644 (file)
@@ -833,8 +833,8 @@ void LyXText::RedoParagraphs(LyXCursor const & cur,
                first_phys_par = tmprow->par->FirstPhysicalPar();
                // find the first row of the paragraph
                if (first_phys_par != tmprow->par)
-                       while (tmprow->previous
-                              && tmprow->previous->par != first_phys_par) {
+                       while (tmprow->previous &&
+                              (tmprow->previous->par != first_phys_par)) {
                                tmprow = tmprow->previous;
                                y -= tmprow->height;
                        }