]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetcollapsable.C
* support/os_unix.C (canAutoOpen, autoOpenFile): on Mac OS X, use
[lyx.git] / src / insets / insetcollapsable.C
index c12fb7bed9fc5d6d73f94fa3f108ecc0e10ad026..75b9c195a1de21e9d9e0daef409eea032026bcc3 100644 (file)
@@ -161,7 +161,8 @@ bool InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
                if (status() == Open) {
                        InsetText::metrics(mi, textdim_);
                        // This expression should not contain mi.base.texwidth
-                       openinlined_ = textdim_.wid < 0.5 * mi.base.bv->workWidth();
+                       openinlined_ = !hasFixedWidth() 
+                               && textdim_.wid < 0.5 * mi.base.bv->workWidth();
                        if (openinlined_) {
                                // Correct for button width, and re-fit
                                mi.base.textwidth -= dim.wid;
@@ -320,8 +321,12 @@ void InsetCollapsable::doDispatch(LCursor & cur, FuncRequest & cmd)
        switch (cmd.action) {
        case LFUN_MOUSE_PRESS:
                if (cmd.button() == mouse_button::button1 && hitButton(cmd)) {
+                       // reset selection if necessary (see bug 3060)
+                       if (cur.selection())
+                               cur.bv().cursor().clearSelection();
+                       else
+                               cur.noUpdate();
                        cur.dispatched();
-                       cur.noUpdate();
                        break;
                }
                if (status() == Inlined)
@@ -356,8 +361,11 @@ void InsetCollapsable::doDispatch(LCursor & cur, FuncRequest & cmd)
                        break;
                }
 
-               if (cmd.button() == mouse_button::button1 && hitButton(cmd)
-                       && !cur.selection()) {
+               if (cmd.button() == mouse_button::button1 && hitButton(cmd)) {
+                       // if we are selecting, we do not want to
+                       // toggle the inset.
+                       if (cur.selection())
+                               break;
                        // Left button is clicked, the user asks to
                        // toggle the inset visual state.
                        cur.dispatched();
@@ -374,7 +382,8 @@ void InsetCollapsable::doDispatch(LCursor & cur, FuncRequest & cmd)
                }
 
                // The mouse click is within the opened inset.
-               InsetText::doDispatch(cur, cmd);
+               if (status() == Open)
+                       InsetText::doDispatch(cur, cmd);
                break;
 
        case LFUN_INSET_TOGGLE: