> //If there is a selection, return the containing inset menu  
>  537         if (d->cursor_.selection())  
>  538                 return d->cursor_.inset().contextMenu(*this, x,
y);  

Is it now ensured that you click on the selection and not outside the
selection ?



The folowing patch will solve the problem of bug 5156 discussed before.
Selecting the character at position 6 gives a selectionEnd at pos 7 and
a selectionBegin at pos 6. Checking for the current selection using <=
and >= always results in two characters being marked as selection. This
is wrong, so I changed <= into <. This probably is the case at a lot
more places in the code. 

Index: src/Text3.cpp
===================================================================
--- src/Text3.cpp       (revision 26147)
+++ src/Text3.cpp       (working copy)
@@ -1184,7 +1185,7 @@
                        // Don't do anything if we right-click a
                        // selection, a context menu will popup.
                        if (bvcur.selection() && cur >=
bvcur.selectionBegin()
-                           && cur <= bvcur.selectionEnd()) {
+                           && cur < bvcur.selectionEnd()) {
                                cur.noUpdate();
                                return;


About the dissolve inset items and stuff. I added this to the code and
it solves the problem (a bit), but I have to try and figure out what the
exact behaviour is. It is more or less copied from the inset-settings
code. 

If I understand correctly, LyX is designed such that you can always
enter a lfun into the program bar. As a consequence, the inset-dissolve
LFUN only has information about where the cursor is, not about where the
user clicked. Thus, if you have a nested inset with the cursor right in
front of the inset and you right-click the button of any of the two
insets, it is practically impossible for the inset-dissolve code to know
which button was clicked. Unless cur or cur.bv().cursor() points to the
button that was clicked. Please help me with this?

Index: src/Text3.cpp
===================================================================
--- src/Text3.cpp       (revision 26147)
+++ src/Text3.cpp       (working copy)
@@ -2103,6 +2105,14 @@
                } else {
                        enable = !isMainText(cur.bv().buffer()) 
                                 && cur.inset().nargs() == 1;
+                       if( !enable )
+                       {
+                               Inset * next_inset = cur.nextInset();
+                               if (next_inset) {
+                                       enable = next_inset->nargs() ==
1;
+                               }
+                       }
+
                }
                break;


Then, I altered the InsetNote code to give a context-edit menu when you
right-click the text-part and a context-note menu when you right-click
the button. This code is probably useful for all InsetCollapsables, so
this code has to be moved to that class. 

Index: src/insets/InsetNote.cpp
===================================================================
--- src/insets/InsetNote.cpp    (revision 26147)
+++ src/insets/InsetNote.cpp    (working copy)
@@ -339,9 +339,12 @@
 }
 
 
-docstring InsetNote::contextMenu(BufferView const &, int, int) const
+docstring InsetNote::contextMenu(BufferView const &, int x, int y)
const
 {
-       return from_ascii("context-note");
+       if( hitButton(x, y) )
+               return from_ascii("context-note");
+       else
+               return from_ascii("context-edit");
 }
 

Last, Jmarc: you changed the code below, but I think you should only
update the cursor position when the current cursor position is outside
the Inset. Otherwise when you are editing an Inset, you want to alter
the Inset in any way by right-clicking the button, LyX will move your
cursor outside the Inset. This is clearly not what you want.

Index: src/insets/InsetCollapsable.cpp
===================================================================
--- src/insets/InsetCollapsable.cpp     (revision 26147)
+++ src/insets/InsetCollapsable.cpp     (working copy)
@@ -495,7 +504,14 @@
                        case mouse_button::button3:
                                // Pass the command to the enclosing
InsetText,
                                // so that the cursor gets set.
-                               cur.undispatched();
+                               if( cur.bv().cursor().isInside( this ) )
+                               {
+                                       cur.noUpdate();
+                               }
+                               else
+                               {
+                                       cur.undispatched();
+                               }
                                break;
                        case mouse_button::none:
                        case mouse_button::button2:


Reply via email to