From e5d7d21ed7a2be4dc01f23f96e67716d9b9ee11c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Fri, 24 Mar 2000 13:24:58 +0000 Subject: [PATCH] Finally fixed the problems with clicking on insets git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@625 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 15 +++++++++++++++ src/BufferView.C | 27 ++++++++++++++++++++------- src/insets/insetcollapsable.C | 7 ++----- src/insets/insetert.C | 8 ++++++++ src/insets/insetert.h | 2 ++ src/mathed/formula.C | 24 +++++++++++++----------- src/text2.C | 4 ++-- 7 files changed, 62 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index feca0d7ab7..471e5c0a85 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2000-03-24 Juergen Vigna + + * 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 * src/lyx_main.C (easyParse): Removed misplaced gui=false which diff --git a/src/BufferView.C b/src/BufferView.C index 926f77959a..abf7d70835 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -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; } diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index fe51decf1a..735439b563 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -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); } diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 27ddcdd7d8..ad7cb29f46 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -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; +} diff --git a/src/insets/insetert.h b/src/insets/insetert.h index cea113cb60..b060072408 100644 --- a/src/insets/insetert.h +++ b/src/insets/insetert.h @@ -44,6 +44,8 @@ public: /// void SetFont(BufferView *, LyXFont const &, bool toggleall = false); /// + void Edit(BufferView *, int, int, unsigned int); + /// }; #endif diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 430fe075ec..564f78050b 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -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); } diff --git a/src/text2.C b/src/text2.C index a24bd80ee9..f69ff60516 100644 --- a/src/text2.C +++ b/src/text2.C @@ -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; } -- 2.39.2